winston-cls-formatter
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

winston-cls-formatter

codecov CircleCI FOSSA Status

Install

npm i winston-cls-formatter

Quickstart

const winston = require('winston');
const winstonClsFormatter = require('winston-cls-formatter');
 
// cls is some Continuation Local Storage management instance that is already bound to a session
 
const logger = winston.createLogger({
  transports: [new winston.transports.Console()],
  format: clsFormatter({ cls })
});
 
cls.set('context', { a: 1 });
 
logger.info('hi');
// prints to console: { level: 'info', message: 'hi', a: 1 }

Any object with the methods get(k) and set(k, v) are accepted as a cls arg. This can allow this formatter to work in many more scenarios.

Better docs to come down the line!

Package Sidebar

Install

npm i winston-cls-formatter

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

4.17 kB

Total Files

5

Last publish

Collaborators

  • matts310