Name: js-handler/node_modules/restify/node_modules/bunyan/examples/hi.js
| 1: | var Logger = require('../lib/bunyan'); |
| 2: | |
| 3: | // Basic usage. |
| 4: | var log = new Logger({name: 'myapp', level: 'info', src: true}); |
| 5: | |
| 6: | // isInfoEnabled replacement |
| 7: | console.log('log.info() is:', log.info()) |
| 8: | |
| 9: | // `util.format`-based printf handling |
| 10: | log.info('hi'); |
| 11: | log.info('hi', 'trent'); |
| 12: | log.info('hi %s there', true); |
| 13: | |
| 14: | // First arg as an object adds fields to the log record. |
| 15: | log.info({foo:'bar', multiline:'one\ntwo\nthree'}, 'hi %d', 1, 'two', 3); |
| 16: | |
| 17: | |
| 18: | // Shows `log.child(...)` to specialize a logger for a sub-component. |
| 19: | console.log('\n') |
| 20: | |
| 21: | function Wuzzle(options) { |
| 22: | this.log = options.log; |
| 23: | this.log.info('creating a wuzzle') |
| 24: | } |
| 25: | |
| 26: | Wuzzle.prototype.woos = function () { |
| 27: | this.log.warn('This wuzzle is woosey.') |
| 28: | } |
| 29: | |
| 30: | var wuzzle = new Wuzzle({log: log.child({component: 'wuzzle'})}); |
| 31: | wuzzle.woos(); |
| 32: | log.info('done with the wuzzle') |
