node-bunyan-lite/examples/src.js

26 lines
606 B
JavaScript
Raw Normal View History

// Show the usage of `src: true` config option to get log call source info in
// log records (the `src` field).
var Logger = require('../lib/bunyan');
2012-06-05 06:19:39 +00:00
var log = new Logger({name: 'src-example', src: true});
2012-06-05 06:19:39 +00:00
log.info('one');
log.info('two');
function doSomeFoo() {
2012-06-05 06:19:39 +00:00
log.info({foo:'bar'}, 'three');
}
doSomeFoo();
function Wuzzle(options) {
this.log = options.log;
2012-06-05 06:19:39 +00:00
this.log.info('creating a wuzzle')
}
Wuzzle.prototype.woos = function () {
2012-06-05 06:19:39 +00:00
this.log.warn('This wuzzle is woosey.')
}
2012-06-05 06:19:39 +00:00
var wuzzle = new Wuzzle({log: log.child({component: 'wuzzle'})});
wuzzle.woos();
2012-06-05 06:19:39 +00:00
log.info('done with the wuzzle')