From 8f1c8adcd7056ed1c7ee09597b294689282471b2 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 10 Apr 2012 15:32:33 -0700 Subject: [PATCH] color 'src' info red in default bunyan CLI coloring --- CHANGES.md | 7 +++++++ bin/bunyan | 1 + examples/hi.js | 7 +++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 926d701..fd5070d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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. diff --git a/bin/bunyan b/bin/bunyan index f89d9b7..2e11df2 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -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; diff --git a/examples/hi.js b/examples/hi.js index 67ee20f..0afac83 100644 --- a/examples/hi.js +++ b/examples/hi.js @@ -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") -