Skip to content

Instantly share code, notes, and snippets.

@howarddierking
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save howarddierking/7f0dac11809e571651c3 to your computer and use it in GitHub Desktop.
Save howarddierking/7f0dac11809e571651c3 to your computer and use it in GitHub Desktop.
testing bunyan
var bunyan = require('bunyan').createLogger({
name: "foo",
streams: [
{
stream: process.stdout,
level: "trace"
}
]
});
var logger = bunyan;
logger.info('this is an informational message');
logger.warn('this is a warning message');
logger.error(new Error('some error message'), 'this is an error message');
// node app.js
// -> {"name":"foo","hostname":"13MBP-10303.local","pid":10851,"level":30,"msg":"this is an informational message","time":"2014-10-22T22:37:48.997Z","v":0}
@trentm
Copy link

trentm commented Oct 24, 2014

@howarddierking I can't repro:

$ node bunyan.js
{"name":"foo","hostname":"grape.local","pid":83569,"level":30,"msg":"this is an informational message","time":"2014-10-24T00:09:23.155Z","v":0}
{"name":"foo","hostname":"grape.local","pid":83569,"level":40,"msg":"this is a warning message","time":"2014-10-24T00:09:23.157Z","v":0}
{"name":"foo","hostname":"grape.local","pid":83569,"level":50,"err":{"message":"some error message","name":"Error","stack":"Error: some error message\n    at Object.<anonymous> (/Users/trentm/tmp/play/bunyan.js:15:14)\n    at Module._compile (module.js:456:26)\n    at Object.Module._extensions..js (module.js:474:10)\n    at Module.load (module.js:356:32)\n    at Function.Module._load (module.js:312:12)\n    at Function.Module.runMain (module.js:497:10)\n    at startup (node.js:119:16)\n    at node.js:906:3"},"msg":"this is an error message","time":"2014-10-24T00:09:23.158Z","v":0}
[17:09:23 trentm@grape:~/tmp/play]
$ json -f node_modules/bunyan/package.json version
1.2.0

What version of bunyan are you using?

@Aashima89
Copy link

Is this issue resolved? I am really curious to know what @howard asked since I am facing the same issue. Even though I throw an error but my code only displays INFO level or DEBUG info as per level set by me.

Does bunyan not follow priority levels here?
By default they are like
TRACE = 10
DEBUG = 20
INFO = 30
WARN = 40
ERROR = 50
FATAL = 60

So if i set level to 30 , I should get all logs for INFO, WARN , ERROR and FATAL
and if I set it to 20, I should get logs for DEBUG, INFO, WARN , ERROR and FATAL?

Just trying to understand the basic functioning of bunyan in node here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment