--no-color option

This commit is contained in:
Trent Mick 2012-02-23 13:00:53 -08:00
parent 92a2e9d005
commit 887f407807
2 changed files with 13 additions and 9 deletions

View file

@ -4,10 +4,11 @@
- ANSI coloring output from `bunyan` CLI tool (for the default output mode/style). - ANSI coloring output from `bunyan` CLI tool (for the default output mode/style).
Also add the '--color' option to force coloring if the output stream is not Also add the '--color' option to force coloring if the output stream is not
a TTY, e.g. `cat my.log | bunyan --color | less -R`. a TTY, e.g. `cat my.log | bunyan --color | less -R`. Use `--no-color` to
- Add 'level' field to log record before custom fields for that record. This just disable coloring, e.g. if your terminal doesn't support ANSI codes.
means that the raw record JSON will show the 'level' field earlier, which is a bit - Add 'level' field to log record before custom fields for that record. This
nicer for raw reading. just means that the raw record JSON will show the 'level' field earlier,
which is a bit nicer for raw reading.
## bunyan 0.6.4 ## bunyan 0.6.4
@ -72,7 +73,7 @@
This will prevent `log.info` et al throwing on record fields that cannot be This will prevent `log.info` et al throwing on record fields that cannot be
represented as JSON. An error will be printed on stderr and a clipped log represented as JSON. An error will be printed on stderr and a clipped log
record emitted with a 'bunyanMsg' key including error details. E.g.: record emitted with a 'bunyanMsg' key including error details. E.g.:
bunyan: ERROR: could not stringify log record from /Users/trentm/tm/node-bunyan/examples/unstringifyable.js:12: TypeError: Converting circular structure to JSON bunyan: ERROR: could not stringify log record from /Users/trentm/tm/node-bunyan/examples/unstringifyable.js:12: TypeError: Converting circular structure to JSON
{ {
"name": "foo", "name": "foo",
@ -80,8 +81,8 @@
"bunyanMsg": "bunyan: ERROR: could not stringify log record from /Users/trentm/tm/node-bunyan/examples/unstringifyable.js:12: TypeError: Converting circular structure to JSON", "bunyanMsg": "bunyan: ERROR: could not stringify log record from /Users/trentm/tm/node-bunyan/examples/unstringifyable.js:12: TypeError: Converting circular structure to JSON",
... ...
Some timing shows this does effect log speed: Some timing shows this does effect log speed:
$ node tools/timeguard.js # before $ node tools/timeguard.js # before
Time try/catch-guard on JSON.stringify: Time try/catch-guard on JSON.stringify:
- log.info: 0.07365ms per iteration - log.info: 0.07365ms per iteration
@ -131,7 +132,7 @@
- `log.child(options[, simple])` Added `simple` boolean arg. Set `true` to - `log.child(options[, simple])` Added `simple` boolean arg. Set `true` to
assert that options only add fields (no config changes). Results in a 10x assert that options only add fields (no config changes). Results in a 10x
speed increase in child creation. See "tools/timechild.js". On my Mac, speed increase in child creation. See "tools/timechild.js". On my Mac,
"fast child" creation takes about 0.001ms. IOW, if your app is dishing "fast child" creation takes about 0.001ms. IOW, if your app is dishing
10,000 req/s, then creating a log child for each request will take 10,000 req/s, then creating a log child for each request will take
about 1% of the request time. about 1% of the request time.
@ -155,4 +156,3 @@
## bunyan 0.1.0 ## bunyan 0.1.0
First release. First release.

View file

@ -137,6 +137,7 @@ function printHelp() {
util.puts(""); util.puts("");
util.puts(" --color Colorize output. Defaults to try if output"); util.puts(" --color Colorize output. Defaults to try if output");
util.puts(" stream is a TTY."); util.puts(" stream is a TTY.");
util.puts(" --no-color Force no coloring (e.g. terminal doesn't support it)");
util.puts(" -o, --output MODE"); util.puts(" -o, --output MODE");
util.puts(" Specify an output mode/format. One of"); util.puts(" Specify an output mode/format. One of");
util.puts(" paul: (the default) pretty") util.puts(" paul: (the default) pretty")
@ -210,6 +211,9 @@ function parseArgv(argv) {
case "--color": case "--color":
parsed.color = true; parsed.color = true;
break; break;
case "--no-color":
parsed.color = false;
break;
case "-o": case "-o":
case "--output": case "--output":
var name = args.shift(); var name = args.shift();