Skip to content

plan3/cls-named-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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']

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published