Wondering what’s next for npm?Check out our public roadmap! »

    @restorecommerce/logger
    TypeScript icon, indicating that this package has built-in type declarations

    0.6.4 • Public • Published

    logger

    VersionBuild StatusDependenciesCoverage Status

    Opinionated wrapper and configurator for the winston logging toolkit.

    The following transports are supported:

    These transports can be added and configured with a corresponding property in the options hash:

      "console": {
        "handleExceptions": false,
        "level": "silly",
        "colorize": true,
        "prettyPrint": true
      },
      "file": {
        ...
      },
      "elasticsearch": {
        ...
      }

    The logger returns a Winston logger instance which has methods that correspond to the following levels:

    • silly
    • verbose
    • debug
    • info
    • warn
    • error
    • log (generic)

    In addition there is a generic log() function.

    Notes

    Console logger

    A custom format is defined that outputs the rid (request-id) if it is set using cls-rtracer module.

    Elastichsearch logger

    The following changes and transformations are applied to log messages:

    • Adds a @timestamp field with the current date/ time
    • Adds a host property with the current host name
    • Adds a rid (request-id) based on cls-rtracer

    This module also comes with a suitable mapping template and an index pattern that can be imported in Kibana.

    Usage

    Instantiation

    let logger = createLogger(opts);

    Logging

    Logging in general:

    logger.<level>('Textual message');
    
    // or
    
    logger.log(<level>, 'Textual message');

    The parameters for the log statements are built like this:

    logger.info('Textual message');
    
    // or
    
    logger.info({ key: 'value' });
    
    // or
    
    logger.info('Textual message', { key: 'value' });

    No other variants are supported.

    See test.ts and the Winston documentation.

    Install

    npm i @restorecommerce/logger

    DownloadsWeekly Downloads

    469

    Version

    0.6.4

    License

    MIT

    Unpacked Size

    25.6 kB

    Total Files

    19

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar