node-bunyan-lite/examples/hi.js

34 lines
784 B
JavaScript
Raw Normal View History

var Logger = require('../lib/bunyan');
2012-01-30 20:01:15 +00:00
// Basic usage.
var log = new Logger({service: "myapp", level: "info"});
// isInfoEnabled replacement
2012-01-30 06:26:47 +00:00
console.log("log.info() is:", log.info())
// `util.format`-based printf handling
2012-01-30 06:26:47 +00:00
log.info("hi");
log.info("hi", "trent");
log.info("hi %s there", true);
// First arg as an object adds fields to the log record.
2012-01-30 06:26:47 +00:00
log.info({foo:"bar"}, "hi %d", 1, "two", 3);
// Shows `log.child(...)` to specialize a logger for a sub-component.
console.log("\n\n")
2012-01-30 06:26:47 +00:00
2012-01-30 20:01:15 +00:00
function Wuzzle(options) {
this.log = options.log;
this.log.info("creating a wuzzle")
}
Wuzzle.prototype.woos = function () {
2012-01-30 20:40:57 +00:00
this.log.warn("This wuzzle is woosey.")
2012-01-30 20:01:15 +00:00
}
var wuzzle = new Wuzzle({log: log.child({component: "wuzzle"})});
2012-01-30 20:01:15 +00:00
wuzzle.woos();
log.info("done with the wuzzle")
2012-01-30 06:26:47 +00:00