2012-02-06 04:33:57 +00:00
|
|
|
// Show the usage of `src: true` config option to get log call source info in
|
|
|
|
// log records (the `src` field).
|
|
|
|
|
2014-07-25 06:36:50 +00:00
|
|
|
var bunyan = require('../lib/bunyan');
|
2012-02-06 04:33:57 +00:00
|
|
|
|
2014-07-25 06:36:50 +00:00
|
|
|
var log = bunyan.createLogger({name: 'src-example', src: true});
|
2012-02-06 04:33:57 +00:00
|
|
|
|
2012-06-05 06:19:39 +00:00
|
|
|
log.info('one');
|
|
|
|
log.info('two');
|
2012-02-06 04:33:57 +00:00
|
|
|
function doSomeFoo() {
|
2013-03-29 00:42:32 +00:00
|
|
|
log.info({foo:'bar'}, 'three');
|
2012-02-06 04:33:57 +00:00
|
|
|
}
|
|
|
|
doSomeFoo();
|
|
|
|
|
|
|
|
function Wuzzle(options) {
|
2013-03-29 00:42:32 +00:00
|
|
|
this.log = options.log;
|
|
|
|
this.log.info('creating a wuzzle')
|
2012-02-06 04:33:57 +00:00
|
|
|
}
|
|
|
|
Wuzzle.prototype.woos = function () {
|
2013-03-29 00:42:32 +00:00
|
|
|
this.log.warn('This wuzzle is woosey.')
|
2012-02-06 04:33:57 +00:00
|
|
|
}
|
|
|
|
|
2012-06-05 06:19:39 +00:00
|
|
|
var wuzzle = new Wuzzle({log: log.child({component: 'wuzzle'})});
|
2012-02-06 04:33:57 +00:00
|
|
|
wuzzle.woos();
|
2012-06-05 06:19:39 +00:00
|
|
|
log.info('done with the wuzzle')
|