color 'src' info red in default bunyan CLI coloring

master
Trent Mick 2012-04-10 15:32:33 -07:00
parent 6f1433c89b
commit 8f1c8adcd7
3 changed files with 11 additions and 4 deletions

View File

@ -2,6 +2,13 @@
## bunyan 0.6.9 (not yet released)
- Change `bunyan` CLI default output to color "src" info red. Before the "src"
information was uncolored. The "src" info is the filename, line number and
function name resulting from using `src: true` in `Logger` creation. I.e.,
the `(/Users/trentm/tm/node-bunyan/examples/hi.js:10)` in:
[2012-04-10T22:28:58.237Z] INFO: myapp/39339 on banana.local (/Users/trentm/tm/node-bunyan/examples/hi.js:10): hi
- Tweak `bunyan` CLI default output to still show an "err" field if it doesn't
have a "stack" attribute.

View File

@ -380,6 +380,7 @@ function handleLogLine(line, opts, stylize) {
} else {
src = format(" (%s:%d)", s.file, s.line);
}
src = stylize(src, 'green');
}
delete rec.src;

View File

@ -1,7 +1,7 @@
var Logger = require('../lib/bunyan');
// Basic usage.
var log = new Logger({name: "myapp", level: "info"});
var log = new Logger({name: "myapp", level: "info", src: true});
// isInfoEnabled replacement
console.log("log.info() is:", log.info())
@ -12,11 +12,11 @@ log.info("hi", "trent");
log.info("hi %s there", true);
// First arg as an object adds fields to the log record.
log.info({foo:"bar"}, "hi %d", 1, "two", 3);
log.info({foo:"bar", multiline:"one\ntwo\nthree"}, "hi %d", 1, "two", 3);
// Shows `log.child(...)` to specialize a logger for a sub-component.
console.log("\n\n")
console.log("\n")
function Wuzzle(options) {
this.log = options.log;
@ -30,4 +30,3 @@ Wuzzle.prototype.woos = function () {
var wuzzle = new Wuzzle({log: log.child({component: "wuzzle"})});
wuzzle.woos();
log.info("done with the wuzzle")