doc new -c CODE; drop dtrace-provider as optionalDependency (fixes #135); add 'bunyan -0' shortcut
This commit is contained in:
parent
02c1d042e9
commit
660b706479
7 changed files with 93 additions and 36 deletions
1
AUTHORS
1
AUTHORS
|
@ -9,3 +9,4 @@ Michael Hart (https://github.com/mhart)
|
|||
Simon Wade (https://github.com/aexmachina)
|
||||
https://github.com/glenn-murray-bse
|
||||
Chakrit Wichian (https://github.com/chakrit)
|
||||
Patrick Mooney (https://github.com/pfmooney)
|
||||
|
|
61
CHANGES.md
61
CHANGES.md
|
@ -6,9 +6,66 @@ Known issues:
|
|||
bug](https://github.com/TooTallNate/node-gyp/issues/65).
|
||||
|
||||
|
||||
## bunyan 0.23.2 (not yet released)
|
||||
## bunyan 1.0.0 (not yet released)
|
||||
|
||||
- [issue #87] **Backward incompatible change to `-c CODE`** improving
|
||||
performance by over 10x (good!), with a backward incompatible change to
|
||||
semantics (unfortunate), and adding some sugar (good!).
|
||||
|
||||
The `-c CODE` implementation was changed to use a JS function for processing
|
||||
rather than `vm.runInNewContext`. The latter was specatularly slow, so
|
||||
won't be missed. Unfortunately this does mean a few semantic differences in
|
||||
the `CODE`, the most noticeable of which is that **`this` is required to
|
||||
access the object fields:**
|
||||
|
||||
# Bad. Works with bunyan 0.x but not 1.x.
|
||||
$ bunyan -c 'pid === 123' foo.log
|
||||
...
|
||||
|
||||
# Good. Works with all versions of bunyan
|
||||
$ bunyan -c 'this.pid === 123' foo.log
|
||||
...
|
||||
|
||||
The old behaviour of `-c` can be restored with the `BUNYAN_EXEC=vm`
|
||||
environment variable:
|
||||
|
||||
$ BUNYAN_EXEC=vm bunyan -c 'pid === 123' foo.log
|
||||
...
|
||||
|
||||
Some sugar was also added: the TRACE, DEBUG, ... constants are defined, so
|
||||
one can:
|
||||
|
||||
$ bunyan -c 'this.level >= ERROR && this.component === "http"' foo.log
|
||||
...
|
||||
|
||||
And example of the speed improvement on a 10 MiB log example:
|
||||
|
||||
$ time BUNYAN_EXEC=vm bunyan -c 'this.level === ERROR' big.log | cat >slow
|
||||
|
||||
real 0m6.349s
|
||||
user 0m6.292s
|
||||
sys 0m0.110s
|
||||
|
||||
$ time bunyan -c 'this.level === ERROR' big.log | cat >fast
|
||||
|
||||
real 0m0.333s
|
||||
user 0m0.303s
|
||||
sys 0m0.028s
|
||||
|
||||
The change was courtesy Patrick Mooney (https://github.com/pfmooney). Thanks!
|
||||
|
||||
- Add `bunyan -0 ...` shortcut for `bunyan -o bunyan ...`.
|
||||
|
||||
- [issue #135] **Backward incompatible.** Drop dtrace-provider even from
|
||||
`optionalDependencies`. Dtrace-provider has proven a consistent barrier to
|
||||
installing bunyan, because it is a binary dep. Even as an *optional* dep it
|
||||
still caused confusion and install noise.
|
||||
|
||||
Users of Bunyan on dtrace-y platforms (SmartOS, Mac, Solaris) will need to
|
||||
manually `npm install dtrace-provider` themselves to get [Bunyan's
|
||||
dtrace support](https://github.com/trentm/node-bunyan#runtime-log-snooping-via-dtrace)
|
||||
to work. If not installed, bunyan should stub it out properly.
|
||||
|
||||
(nothing yet)
|
||||
|
||||
|
||||
## bunyan 0.23.1
|
||||
|
|
3
Makefile
3
Makefile
|
@ -30,8 +30,9 @@ NON_DTRACE_TEST_FILES := $(shell ls -1 test/*.test.js | grep -v dtrace | xargs)
|
|||
|
||||
#---- Targets
|
||||
|
||||
all:
|
||||
all $(NODEUNIT):
|
||||
npm install
|
||||
npm install dtrace-provider
|
||||
|
||||
# Ensure all version-carrying files have the same version.
|
||||
.PHONY: versioncheck
|
||||
|
|
44
bin/bunyan
44
bin/bunyan
|
@ -1,12 +1,17 @@
|
|||
#!/usr/bin/env node
|
||||
// -*- mode: js -*-
|
||||
//
|
||||
// bunyan -- filter and pretty-print JSON logs, like Bunyan logs.
|
||||
//
|
||||
// See <https://github.com/trentm/node-bunyan>.
|
||||
//
|
||||
/**
|
||||
* Copyright (c) 2014 Trent Mick. All rights reserved.
|
||||
* Copyright (c) 2014 Joyent Inc. All rights reserved.
|
||||
*
|
||||
* bunyan -- filter and pretty-print Bunyan log files (line-delimited JSON)
|
||||
*
|
||||
* See <https://github.com/trentm/node-bunyan>.
|
||||
*
|
||||
* -*- mode: js -*-
|
||||
* vim: expandtab:ts=4:sw=4
|
||||
*/
|
||||
|
||||
var VERSION = '0.23.2';
|
||||
var VERSION = '1.0.0';
|
||||
|
||||
var p = console.log;
|
||||
var util = require('util');
|
||||
|
@ -187,8 +192,8 @@ function printHelp() {
|
|||
p('Filtering options:');
|
||||
p(' -l, --level LEVEL');
|
||||
p(' Only show messages at or above the specified level.');
|
||||
p(' You can specify level *names* or numeric values.');
|
||||
p(' (See "Log Levels" below.)');
|
||||
p(' You can specify level *names* or the internal numeric');
|
||||
p(' values.');
|
||||
p(' -c, --condition CONDITION');
|
||||
p(' Run each log message through the condition and');
|
||||
p(' only show those that return truish. E.g.:');
|
||||
|
@ -218,18 +223,7 @@ function printHelp() {
|
|||
p(' inspect: node.js `util.inspect` output');
|
||||
p(' short: like "long", but more concise');
|
||||
p(' -j shortcut for `-o json`');
|
||||
p('');
|
||||
p('Log Levels:');
|
||||
p(' Either numeric values or their associated strings are valid for the');
|
||||
p(' -l|--level argument. However, -c|--condition scripts will see a numeric');
|
||||
p(' "level" value, not a string.');
|
||||
p('');
|
||||
Object.keys(levelFromName).forEach(function (name) {
|
||||
var n = name;
|
||||
while (n.length < 6)
|
||||
n += ' ';
|
||||
p(' %s %d', n, levelFromName[name]);
|
||||
});
|
||||
p(' -0 shortcut for `-o bunyan`');
|
||||
p('');
|
||||
p('Environment Variables:');
|
||||
p(' BUNYAN_NO_COLOR Set to a non-empty value to force no output ');
|
||||
|
@ -490,6 +484,9 @@ function parseArgv(argv) {
|
|||
case '-j': // output with JSON.stringify
|
||||
parsed.outputMode = OM_JSON;
|
||||
break;
|
||||
case '-0':
|
||||
parsed.outputMode = OM_BUNYAN;
|
||||
break;
|
||||
case '-p':
|
||||
if (!parsed.pids) {
|
||||
parsed.pids = [];
|
||||
|
@ -530,8 +527,9 @@ function parseArgv(argv) {
|
|||
case '-c':
|
||||
case '--condition':
|
||||
var condition = args.shift();
|
||||
if (Boolean(process.env.JSON_EXEC &&
|
||||
process.env.JSON_EXEC === 'vm')) {
|
||||
if (Boolean(process.env.BUNYAN_EXEC &&
|
||||
process.env.BUNYAN_EXEC === 'vm'))
|
||||
{
|
||||
parsed.condVm = parsed.condVm || [];
|
||||
var scriptName = 'bunyan-condition-'+parsed.condVm.length;
|
||||
var code = condDefines + condition;
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Trent Mick. All rights reserved.
|
||||
* Copyright (c) 2013 Joyent Inc. All rights reserved.
|
||||
/**
|
||||
* Copyright (c) 2014 Trent Mick. All rights reserved.
|
||||
* Copyright (c) 2014 Joyent Inc. All rights reserved.
|
||||
*
|
||||
* The bunyan logging library for node.js.
|
||||
*
|
||||
* -*- mode: js -*-
|
||||
* vim: expandtab:ts=4:sw=4
|
||||
*/
|
||||
|
||||
var VERSION = '0.23.2';
|
||||
var VERSION = '1.0.0';
|
||||
|
||||
// Bunyan log format version. This becomes the 'v' field on all log records.
|
||||
// `0` is until I release a version '1.0.0' of node-bunyan. Thereafter,
|
||||
|
|
10
package.json
10
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "bunyan",
|
||||
"version": "0.23.2",
|
||||
"description": "a JSON Logger library for node.js services",
|
||||
"version": "1.0.0",
|
||||
"description": "a JSON logging library for node.js services",
|
||||
"author": "Trent Mick <trentm@gmail.com> (http://trentm.com)",
|
||||
"main": "./lib/bunyan.js",
|
||||
"bin": {
|
||||
|
@ -17,10 +17,10 @@
|
|||
|
||||
"dependencies": {
|
||||
},
|
||||
"// comment": "'mv' required for RotatingFileStream",
|
||||
"// comment: mv": "'mv' required for RotatingFileStream",
|
||||
"// comment: dtrace": "dtrace-provider required for Bunyan dtrace features, but install is notoriously problematic on some plats (#135)",
|
||||
"optionalDependencies": {
|
||||
"mv": "~2",
|
||||
"dtrace-provider": "0.2.8"
|
||||
"mv": "~2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodeunit": "0.7.4",
|
||||
|
|
|
@ -330,7 +330,6 @@ test('--condition "this.level === TRACE', function (t) {
|
|||
});
|
||||
|
||||
// multiple
|
||||
// not sure if this is a bug or a feature. let's call it a feature!
|
||||
test('multiple --conditions', function (t) {
|
||||
var expect = [
|
||||
'# levels\n',
|
||||
|
|
Loading…
Reference in a new issue