Notoriously Punctual Manatee

    cls-named-logger

    1.0.5 • Public • Published

    CLS Named Logger Build Status

    Installtion

    npm install cls-named-logger

    Usage

    const loggerFactory = require('cls-named-logger')();
    const logger = loggerFactory('debug:namespace');
     
    const clsNamespace = loggerFactory.clsNs;
     
    clsNamespace.run(function() {
        clsNamespace.set('customArg', 123);
        logger.log('Some message');
    });

    or

    const cls = require('continuation-local-storage');
    const clsNamedLogger = require('cls-named-logger');
     
    const clsNamespace = cls.createNamespace(clsNamespaceName);
    const logger = clsNamedLogger(clsNamespace)('debug:namespace');
     
    clsNamespace.run(function() {
        clsNamespace.set('customArg', 123);
        logger.log('Some message');
    });

    It will append custom CLS namespace values to the end of the message. In :point-up: example it will be:

    Some message [customArg=123]

    It exposes the same log levels as console, which are: ['log', 'info', 'debug', 'trace', 'warn', 'error']

    Keywords

    Install

    npm i cls-named-logger

    DownloadsWeekly Downloads

    1

    Version

    1.0.5

    License

    ISC

    Last publish

    Collaborators

    • plan3-relate