javascript - Show debug messages in console in bunyan -


child.log.info('info'); child.log.debug('debug'); 

i use following command:

node app.js | bunyan -o short -l debug 

however shows info. not show debug. i'd ot display debug messages in console, doing wrong?

when create logger, use level option set level @ bunyan emit log messages:

var log = bunyan.createlogger({ level: "debug" }); 

similarly, use level option set level @ child loggers emit log messages:

var child = log.child({ level: "debug" }); 

this level option set @ time of instantiation determines minimum level of log message emitted bunyan.

the command line switch -l ( or --level ) filter; allows through messages emitted @ given level or above. but, not set minimum level of log message emitted instance of bunyan.

for example, suppose want instance of bunyan emits log messages @ "debug" level or higher. can put following in main.js:

var bunyan = require("bunyan"); var log = bunyan.createlogger({ level: "debug" });  log.trace("nitty gritty info here."); log.debug("eek ork op."); log.info("the red zone loading , unloading only."); 

if run following command line:

node main.js | bunyan 

i see in output:

eek ork op. red zone loading , unloading only. 

notice didn't filter command line , call log.trace() didn't print anything, either.

now, type command line:

node main.js | bunyan -l "debug" 

you'll get:

eek ork op. red zone loading , unloading only. 

the same before.

now, try:

node main.js | bunyan -l "trace" 

you'll still same output before.

why? because instance of bunyan set emit messages @ "debug" level or higher. command-line switch -l filter.

finally, try:

node main.js | bunyan -l "info" 

this time, you'll see:

the red zone loading , unloading only. 

the call log.debug() filtered out.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -