Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bunyan

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunyan - npm Package Compare versions

Comparing version 0.17.0 to 0.18.0

examples/long-running.js

21

CHANGES.md

@@ -9,2 +9,23 @@ # bunyan Changelog

## bunyan 0.18.0
- Automatic paging support in the `bunyan` CLI (similar to `git log` et al).
IOW, `bunyan` will open your pager (by default `less`) and pipe rendered
log output through it. A main benefit of this is getting colored logs with
a pager without the pain. Before you had to explicit use `--color` to tell
bunyan to color output when the output was not a TTY:
bunyan foo.log --color | less -R # before
bunyan foo.log # now
Disable with the `--no-pager` option or the `BUNYAN_NO_PAGER=1` environment
variable.
Limitations: Only supported for node >=0.8. Windows is not supported (at
least not yet).
- Switch test suite to nodeunit (still using a node-tap'ish API via
a helper).
## bunyan 0.17.0

@@ -11,0 +32,0 @@

2

lib/bunyan.js

@@ -7,3 +7,3 @@ /*

var VERSION = '0.17.0';
var VERSION = '0.18.0';

@@ -10,0 +10,0 @@ // Bunyan log format version. This becomes the 'v' field on all log records.

{
"name": "bunyan",
"version": "0.17.0",
"version": "0.18.0",
"description": "a JSON Logger library for node.js services",

@@ -26,3 +26,3 @@ "author": "Trent Mick <trentm@gmail.com> (http://trentm.com)",

"devDependencies": {
"tap": "0.3.3",
"nodeunit": "0.7.4",
"ben": "0.0.0",

@@ -33,4 +33,4 @@ "verror": "1.3.3"

"scripts": {
"test": "tap test/*.js"
"test": "make test"
}
}

@@ -390,3 +390,3 @@ Bunyan is **a simple and fast JSON logging library** for node.js services:

- `v`: Required. Integer. Added by Bunion. Cannot be overriden.
- `v`: Required. Integer. Added by Bunyan. Cannot be overriden.
This is the Bunyan log format version (`require('bunyan').LOG_VERSION`).

@@ -397,3 +397,3 @@ The log version is a single integer. `0` is until I release a version

format. Details will be in "CHANGES.md" (the change log).
- `level`: Required. Integer. Added by Bunion. Cannot be overriden.
- `level`: Required. Integer. Added by Bunyan. Cannot be overriden.
See the "Levels" section.

@@ -407,3 +407,3 @@ - `name`: Required. String. Provided at Logger creation.

- `pid`: Required. Integer. Filled in automatically at Logger creation.
- `time`: Required. String. Added by Bunion. Can be overriden.
- `time`: Required. String. Added by Bunyan. Can be overriden.
The date and time of the event in [ISO 8601

@@ -690,3 +690,5 @@ Extended Format](http://en.wikipedia.org/wiki/ISO_8601) format and in UTC,

"hourly" (means 1h), "daily" (1d), "weekly" (1w), "monthly" (1m),
"yearly" (1y). Rotation is done at the "start"</td>
"yearly" (1y). Rotation is done at the start of the scope: top of the hour (h),
midnight (d), start of Sunday (w), start of the 1st of the month (m),
start of Jan 1st (y).</td>
</tr>

@@ -905,2 +907,3 @@ <tr>

- Bunyan syslog support: <https://github.com/mcavage/node-bunyan-syslog>.
- Bunyan + Graylog2: <https://github.com/mhart/gelf-stream>.
- An example of a Bunyan shim to the Winston logging system:

@@ -907,0 +910,0 @@ <https://github.com/trentm/node-bunyan-winston>.

@@ -11,6 +11,14 @@ /*

format = util.format;
var test = require('tap').test;
var bunyan = require('../lib/bunyan');
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
function Catcher() {

@@ -17,0 +25,0 @@ this.records = [];

@@ -7,5 +7,14 @@ /*

var test = require('tap').test;
var bunyan = require('../lib/bunyan');
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
function CapturingStream(recs) {

@@ -12,0 +21,0 @@ this.recs = recs || [];

@@ -9,6 +9,15 @@ /*

var exec = require('child_process').exec;
var format = require('util').format;
var test = require('tap').test;
var _ = require('util').format;
var debug = console.warn;
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
var BUNYAN = path.resolve(__dirname, '../bin/bunyan');

@@ -28,3 +37,3 @@

exec(BUNYAN + ' --version', function (err, stdout, stderr) {
t.error(err)
t.ifError(err)
t.equal(stdout, 'bunyan ' + version + '\n');

@@ -37,3 +46,3 @@ t.end();

exec(BUNYAN + ' --help', function (err, stdout, stderr) {
t.error(err)
t.ifError(err)
t.ok(stdout.indexOf('General options:') !== -1);

@@ -46,3 +55,3 @@ t.end();

exec(BUNYAN + ' -h', function (err, stdout, stderr) {
t.error(err)
t.ifError(err)
t.ok(stdout.indexOf('General options:') !== -1);

@@ -62,4 +71,5 @@ t.end();

test('simple.log', function (t) {
exec(BUNYAN + ' corpus/simple.log', function (err, stdout, stderr) {
t.error(err)
exec(_('%s %s/corpus/simple.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err)
t.equal(stdout,

@@ -72,5 +82,5 @@ '[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: '

test('cat simple.log', function (t) {
exec(format('cat corpus/simple.log | %s', BUNYAN),
exec(_('cat %s/corpus/simple.log | %s', __dirname, BUNYAN),
function (err, stdout, stderr) {
t.error(err)
t.ifError(err)
t.equal(stdout,

@@ -84,7 +94,8 @@ '[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: '

test('simple.log with color', function (t) {
exec(BUNYAN + ' --color corpus/simple.log', function (err, stdout, stderr) {
t.error(err)
exec(_('%s --color %s/corpus/simple.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err)
t.equal(stdout,
'[2012-02-08T22:56:52.856Z] \u001b[36m INFO\u001b[39m: myservice/123 '
+ 'on example.com: \u001b[36mMy message\u001b[39m\n');
+ 'on example.com: \u001b[36mMy message\u001b[39m\n\u001b[0m');
t.end();

@@ -95,4 +106,5 @@ });

test('extrafield.log', function (t) {
exec(BUNYAN + ' corpus/extrafield.log', function (err, stdout, stderr) {
t.error(err)
exec(_('%s %s/corpus/extrafield.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err)
t.equal(stdout,

@@ -105,9 +117,9 @@ '[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: '

test('extrafield.log with color', function (t) {
exec(BUNYAN + ' --color corpus/extrafield.log',
exec(_('%s --color %s/corpus/extrafield.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.error(err)
t.ifError(err)
t.equal(stdout,
'[2012-02-08T22:56:52.856Z] \u001b[36m INFO\u001b[39m: myservice/123 '
+ 'on example.com: \u001b[36mMy message\u001b[39m'
+ '\u001b[90m (extra=field)\u001b[39m\n');
+ '\u001b[90m (extra=field)\u001b[39m\n\u001b[0m');
t.end();

@@ -118,4 +130,5 @@ });

test('bogus.log', function (t) {
exec(BUNYAN + ' corpus/bogus.log', function (err, stdout, stderr) {
t.error(err)
exec(_('%s %s/corpus/bogus.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err)
t.equal(stdout, 'not a JSON line\n{"hi": "there"}\n');

@@ -127,5 +140,6 @@ t.end();

test('bogus.log -j', function (t) {
exec(BUNYAN + ' -j corpus/bogus.log', function (err, stdout, stderr) {
t.error(err)
t.equal(stdout, 'not a JSON line\n{\n "hi": "there"\n}\n');
exec(_('%s -j %s/corpus/bogus.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err)
t.equal(stdout, 'not a JSON line\n{"hi": "there"}\n');
t.end();

@@ -136,5 +150,6 @@ });

test('all.log', function (t) {
exec(BUNYAN + ' corpus/all.log', function (err, stdout, stderr) {
exec(_('%s %s/corpus/all.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
// Just make sure don't blow up on this.
t.error(err)
t.ifError(err)
t.end();

@@ -145,3 +160,4 @@ });

test('simple.log doesnotexist1.log doesnotexist2.log', function (t) {
exec(BUNYAN + ' corpus/simple.log doesnotexist1.log doesnotexist2.log',
exec(_('%s %s/corpus/simple.log doesnotexist1.log doesnotexist2.log',
BUNYAN, __dirname),
function (err, stdout, stderr) {

@@ -167,5 +183,5 @@ t.ok(err)

test('multiple logs', function (t) {
exec(BUNYAN + ' corpus/log1.log corpus/log2.log',
exec(_('%s %s/corpus/log1.log %s/corpus/log2.log', BUNYAN, __dirname, __dirname),
function (err, stdout, stderr) {
t.error(err);
t.ifError(err);
t.equal(stdout, [

@@ -187,4 +203,5 @@ '[2012-05-08T16:57:55.586Z] INFO: agent1/73267 on headnode: message\n',

test('log1.log.gz', function (t) {
exec(BUNYAN + ' corpus/log1.log.gz', function (err, stdout, stderr) {
t.error(err);
exec(_('%s %s/corpus/log1.log.gz', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err);
t.equal(stdout, [

@@ -201,5 +218,5 @@ '[2012-05-08T16:57:55.586Z] INFO: agent1/73267 on headnode: message\n',

test('mixed text and gzip logs', function (t) {
exec(BUNYAN + ' corpus/log1.log.gz corpus/log2.log',
exec(_('%s %s/corpus/log1.log.gz %s/corpus/log2.log', BUNYAN, __dirname, __dirname),
function (err, stdout, stderr) {
t.error(err);
t.ifError(err);
t.equal(stdout, [

@@ -234,7 +251,9 @@ '[2012-05-08T16:57:55.586Z] INFO: agent1/73267 on headnode: message\n',

].join('');
exec(BUNYAN + ' -l 40 corpus/all.log', function (err, stdout, stderr) {
t.error(err);
exec(_('%s -l 40 %s/corpus/all.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err);
t.equal(stdout, expect);
exec(BUNYAN + ' --level 40 corpus/all.log', function (err, stdout, stderr) {
t.error(err);
exec(_('%s --level 40 %s/corpus/all.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err);
t.equal(stdout, expect);

@@ -257,9 +276,9 @@ t.end();

].join('');
exec(BUNYAN + ' -c "level === 10 && pid === 123" corpus/all.log',
exec(_('%s -c "level === 10 && pid === 123" %s/corpus/all.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.error(err);
t.ifError(err);
t.equal(stdout, expect);
exec(BUNYAN + ' --condition "level === 10 && pid === 123" corpus/all.log',
exec(_('%s --condition "level === 10 && pid === 123" %s/corpus/all.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.error(err);
t.ifError(err);
t.equal(stdout, expect);

@@ -284,6 +303,7 @@ t.end();

].join('');
exec(BUNYAN + ' corpus/all.log ' +
'-c "if (level === 40) pid = 1; true" ' +
'-c "pid === 1"', function (err, stdout, stderr) {
t.error(err);
exec(_('%s %s/corpus/all.log ' +
'-c "if (level === 40) pid = 1; true" ' +
'-c "pid === 1"', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err);
t.equal(stdout, expect);

@@ -332,4 +352,5 @@ t.end();

].join('\n') + '\n';
exec(BUNYAN + ' corpus/withreq.log', function (err, stdout, stderr) {
t.error(err);
exec(_('%s %s/corpus/withreq.log', BUNYAN, __dirname),
function (err, stdout, stderr) {
t.ifError(err);
t.equal(stdout, expect);

@@ -339,10 +360,1 @@ t.end();

});
test('non-object res field', function (t) {
var expect = '[2012-10-10T16:14:07.610Z] INFO: cnapi.get_existing_nics/24440 on 710c784f-6aa5-428c-9074-e046c3af884e: got existing: 02:08:20:d7:53:e0 (job_uuid=3499b13e-dbca-4331-b13a-f164c0da320a, nic=<unknown>, res="error: Unknown nic \\"020820d753e0\\"")\n';
exec(BUNYAN + ' corpus/non-object-res.log', function (err, stdout, stderr) {
t.error(err);
t.equal(stdout, expect);
t.end();
});
});

@@ -7,15 +7,22 @@ /*

var test = require('tap').test;
var bunyan = require('../lib/bunyan'),
Logger = bunyan;
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
test('ensure Logger creation options', function (t) {
t.throws(function () { new Logger(); },
{name: 'TypeError', message: 'options (object) is required'},
'options (object) is required',
'no options should throw');
t.throws(function () { new Logger({}); },
{name: 'TypeError', message: 'options.name (string) is required'},
'options.name (string) is required',
'no options.name should throw');

@@ -33,3 +40,3 @@

t.throws(function () { new Logger(options); },
{name: 'TypeError', message: 'invalid options.streams: must be an array'},
'invalid options.streams: must be an array',
'"streams" must be an array');

@@ -39,6 +46,3 @@

t.throws(function () { new Logger(options); },
{
name: 'TypeError',
message: 'invalid options.serializers: must be an object'
},
'invalid options.serializers: must be an object',
'"serializers" cannot be a string');

@@ -48,6 +52,3 @@

t.throws(function () { new Logger(options); },
{
name: 'TypeError',
message: 'invalid options.serializers: must be an object'
},
'invalid options.serializers: must be an object',
'"serializers" cannot be an array');

@@ -61,7 +62,7 @@

t.throws(function () { bunyan.createLogger(); },
{name: 'TypeError', message: 'options (object) is required'},
'options (object) is required',
'no options should throw');
t.throws(function () { bunyan.createLogger({}); },
{name: 'TypeError', message: 'options.name (string) is required'},
'options.name (string) is required',
'no options.name should throw');

@@ -79,3 +80,3 @@

t.throws(function () { bunyan.createLogger(options); },
{name: 'TypeError', message: 'invalid options.streams: must be an array'},
'invalid options.streams: must be an array',
'"streams" must be an array');

@@ -85,6 +86,3 @@

t.throws(function () { bunyan.createLogger(options); },
{
name: 'TypeError',
message: 'invalid options.serializers: must be an object'
},
'invalid options.serializers: must be an object',
'"serializers" cannot be a string');

@@ -94,6 +92,3 @@

t.throws(function () { bunyan.createLogger(options); },
{
name: 'TypeError',
message: 'invalid options.serializers: must be an object'
},
'invalid options.serializers: must be an object',
'"serializers" cannot be an array');

@@ -115,6 +110,3 @@

t.throws(function () { log.child({name: 'foo'}); },
{
name: 'TypeError',
message: 'invalid options.name: child cannot set logger name'
},
'invalid options.name: child cannot set logger name',
'child cannot change name');

@@ -129,3 +121,3 @@

t.throws(function () { log.child(options); },
{name: 'TypeError', message: 'invalid options.streams: must be an array'},
'invalid options.streams: must be an array',
'"streams" must be an array');

@@ -135,6 +127,3 @@

t.throws(function () { log.child(options); },
{
name: 'TypeError',
message: 'invalid options.serializers: must be an object'
},
'invalid options.serializers: must be an object',
'"serializers" cannot be a string');

@@ -144,6 +133,3 @@

t.throws(function () { log.child(options); },
{
name: 'TypeError',
message: 'invalid options.serializers: must be an object'
},
'invalid options.serializers: must be an object',
'"serializers" cannot be an array');

@@ -150,0 +136,0 @@

@@ -7,5 +7,13 @@ /*

var test = require('tap').test;
var Logger = require('../lib/bunyan.js');
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
var Stream = require('stream').Stream;

@@ -65,3 +73,9 @@ var outstr = new Stream;

output.forEach(function (o, i) {
t.has(o, expect[i], 'log item ' + i + ' matches');
// Drop variable parts for comparison.
delete o.hostname;
delete o.pid;
delete o.time;
// Hack object/dict comparison: JSONify.
t.equal(JSON.stringify(o), JSON.stringify(expect[i]),
'log item ' + i + ' matches');
});

@@ -77,3 +91,3 @@ t.end();

outstr.end();
t.pass('did not throw');
t.ok('did not throw');
});

@@ -10,6 +10,13 @@ /*

var test = require('tap').test;
var bunyan = require('../lib/bunyan');
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
// Determine if we can run the dtrace tests.

@@ -16,0 +23,0 @@ var dtracePlats = ['sunos', 'darwin', 'freebsd'];

@@ -8,9 +8,17 @@ /*

var test = require('tap').test;
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
test('error event on log write', function (t) {
LOG_PATH = '/this/path/is/bogus.log'
var log = new Logger({name: 'error-event', streams: [{path: LOG_PATH}]});
t.plan(5);
var log = bunyan.createLogger(
{name: 'error-event', streams: [{path: LOG_PATH}]});
log.on('error', function (err, stream) {

@@ -17,0 +25,0 @@ t.ok(err, 'got err in error event: ' + err);

@@ -7,6 +7,14 @@ /*

var test = require('tap').test;
var Logger = require('../lib/bunyan');
var bunyan = require('../lib/bunyan');
var log1 = new Logger({
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
var log1 = bunyan.createLogger({
name: 'log1',

@@ -21,3 +29,3 @@ streams: [

var log2 = new Logger({
var log2 = bunyan.createLogger({
name: 'log2',

@@ -37,3 +45,3 @@ streams: [

test('log.LEVEL() -> boolean', function (t) {
t.equal(log1.trace(), false)
t.equal(log1.trace(), false, 'log1.trace() is false')
t.equal(log1.debug(), false)

@@ -40,0 +48,0 @@ t.equal(log1.info(), true)

@@ -7,5 +7,13 @@ /*

var test = require('tap').test;
var bunyan = require('../lib/bunyan');
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
test('bunyan.<LEVEL>s', function (t) {

@@ -36,2 +44,1 @@ t.ok(bunyan.TRACE, 'TRACE');

});

@@ -8,5 +8,11 @@ /*

var format = require('util').format;
var test = require('tap').test;
var Logger = require('../lib/bunyan');
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;

@@ -13,0 +19,0 @@

@@ -5,6 +5,14 @@ /*

var test = require('tap').test;
var Logger = require('../lib/bunyan');
var ringbuffer = new Logger.RingBuffer({ 'limit': 5 });
// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
var log1 = new Logger({

@@ -11,0 +19,0 @@ name: 'log1',

@@ -7,3 +7,2 @@ /*

var test = require('tap').test;
var http = require('http');

@@ -14,3 +13,11 @@

// node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js');
var after = tap4nodeunit.after;
var before = tap4nodeunit.before;
var test = tap4nodeunit.test;
function CapturingStream(recs) {

@@ -17,0 +24,0 @@ this.recs = recs;

- man page for the bunyan CLI (refer to it in the readme)
- full-on docs. The readme is too clunky now.
- paging
- coloring bug: in less the indented extra info lines only have the first
line colored. Do we need the ANSI char on *each* line? That'll be
slower.
- `tail -f`-like support

@@ -10,2 +11,5 @@ - 1.0 with `v: 1` in log records. Fwd/bwd compat in `bunyan` CLI

- full-on docs
- better examples/
- better coloring
- "template" support for 'rotating-file' stream to get dated rolled files

@@ -12,0 +16,0 @@ - "all" or "off" levels? log4j? logging.py?

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc