Releases: paytm/lgr
Releases · paytm/lgr
Moving away from NPMLOG to Paytm's fork
With this release, we start migrating away from npmlog
to Paytm's fork of npmlog
.
Major changes:
- No more EventEmitter in Paytm's npmlog.
addLevel()
can accept an additional parameter (the output stream for that level).- setOut(), setErr(), flush() will be deprecated soon, as stream information can now be stored at
npmlog
instead of maintaingoutputStream
s anderrorStream
s atlgr
.
Use addLevel() to define your own custom levels.
You can add your own custom levels now.
The level name and priority are mandatory arguments, and
lgr will throw an error if either is missing. You can
define your own style and prefix, npm style.
// mandatory arguments
log.addLevel('wall', 3500);
// optional arguments
log.addLevel('hell', 6666, {fg: 'black', bg: 'red'}, 'HELL!');
`logFormat`s are now customizable for every log level
You can now call log.setLogFormat()
on specific levels.
For example,
/* Set the same format for all levels, when level is not specified */
log.setLogFormat('<%= ts %> [<%= uptime %>] ');
log.log('hello');
// prints -->
// info 2016-05-20 09:39:48 [0] hello
/* Set a different format, for a specific level */
log.setLogFormat('error', 'in <%= __FUNC__ %> at <%= __FILE__ %>:<%= __LINE__ %> ');
log.error(new Error('world'));
// prints -->
// ERR! in (anon) at /Users/sarat/Work/Paytm/lgr/test.js:23 Error: world
/* BEWARE: Calling setLogFormat without a level again overwrites the format for all levels again */
log.setLogFormat('<%= ts %> [<%= uptime %>] ');
log.log('hello world!');
log.error('hello world!');
// prints -->
// info 2016-05-20 09:39:48 [0] hello world!
// ERR! 2016-05-20 09:39:48 [0] hello world!