Comparing version 0.7.0 to 0.8.0
# bunyan Changelog | ||
## bunyan 0.8.0 | ||
- [pull #21] Bunyan loggers now re-emit `fs.createWriteStream` error events. | ||
By github.com/EvanOxfeld. See "examples/handle-fs-error.js" and | ||
"test/error-event.js" for details. | ||
var log = new Logger({name: 'mylog', streams: [{path: FILENAME}]}); | ||
log.on('error', function (err, stream) { | ||
// Handle error writing to or creating FILENAME. | ||
}); | ||
- jsstyle'ing (via `make check`) | ||
## bunyan 0.7.0 | ||
@@ -4,0 +18,0 @@ |
@@ -8,3 +8,3 @@ // Example logging an error: | ||
var log = new Logger({ | ||
name: "myserver", | ||
name: 'myserver', | ||
serializers: { | ||
@@ -16,12 +16,12 @@ err: Logger.stdSerializers.err, // <--- use this | ||
try { | ||
throw new TypeError("boom"); | ||
throw new TypeError('boom'); | ||
} catch (err) { | ||
log.warn({err: err}, "operation went boom: %s", err) // <--- here | ||
log.warn({err: err}, 'operation went boom: %s', err) // <--- here | ||
} | ||
log.info(new TypeError("how about this?")) // <--- alternatively this | ||
log.info(new TypeError('how about this?')) // <--- alternatively this | ||
try { | ||
throw "boom string"; | ||
throw 'boom string'; | ||
} catch (err) { | ||
@@ -31,29 +31,31 @@ log.error(err) | ||
/* | ||
$ node err.js | ../bin/bunyan -j | ||
{ | ||
"name": "myserver", | ||
"hostname": "banana.local", | ||
"err": { | ||
"stack": "TypeError: boom\n at Object.<anonymous> (/Users/trentm/tm/node-bunyan/examples/err.js:15:9)\n at Module._compile (module.js:411:26)\n at Object..js (module.js:417:10)\n at Module.load (module.js:343:31)\n at Function._load (module.js:302:12)\n at Array.0 (module.js:430:10)\n at EventEmitter._tickCallback (node.js:126:26)", | ||
"name": "TypeError", | ||
"message": "boom" | ||
}, | ||
"level": 4, | ||
"msg": "operation went boom: TypeError: boom", | ||
"time": "2012-02-02T04:42:53.206Z", | ||
"v": 0 | ||
} | ||
$ node err.js | ../bin/bunyan | ||
[2012-02-02T05:02:39.412Z] WARN: myserver on banana.local: operation went boom: TypeError: boom | ||
TypeError: boom | ||
at Object.<anonymous> (/Users/trentm/tm/node-bunyan/examples/err.js:15:9) | ||
at Module._compile (module.js:411:26) | ||
at Object..js (module.js:417:10) | ||
at Module.load (module.js:343:31) | ||
at Function._load (module.js:302:12) | ||
at Array.0 (module.js:430:10) | ||
at EventEmitter._tickCallback (node.js:126:26) | ||
*/ | ||
/* BEGIN JSSTYLED */ | ||
/** | ||
* | ||
* $ node err.js | ../bin/bunyan -j | ||
* { | ||
* "name": "myserver", | ||
* "hostname": "banana.local", | ||
* "err": { | ||
* "stack": "TypeError: boom\n at Object.<anonymous> (/Users/trentm/tm/node-bunyan/examples/err.js:15:9)\n at Module._compile (module.js:411:26)\n at Object..js (module.js:417:10)\n at Module.load (module.js:343:31)\n at Function._load (module.js:302:12)\n at Array.0 (module.js:430:10)\n at EventEmitter._tickCallback (node.js:126:26)", | ||
* "name": "TypeError", | ||
* "message": "boom" | ||
* }, | ||
* "level": 4, | ||
* "msg": "operation went boom: TypeError: boom", | ||
* "time": "2012-02-02T04:42:53.206Z", | ||
* "v": 0 | ||
* } | ||
* $ node err.js | ../bin/bunyan | ||
* [2012-02-02T05:02:39.412Z] WARN: myserver on banana.local: operation went boom: TypeError: boom | ||
* TypeError: boom | ||
* at Object.<anonymous> (/Users/trentm/tm/node-bunyan/examples/err.js:15:9) | ||
* at Module._compile (module.js:411:26) | ||
* at Object..js (module.js:417:10) | ||
* at Module.load (module.js:343:31) | ||
* at Function._load (module.js:302:12) | ||
* at Array.0 (module.js:430:10) | ||
* at EventEmitter._tickCallback (node.js:126:26) | ||
* | ||
*/ | ||
/* END JSSTYLED */ |
var Logger = require('../lib/bunyan'); | ||
// Basic usage. | ||
var log = new Logger({name: "myapp", level: "info", src: true}); | ||
var log = new Logger({name: 'myapp', level: 'info', src: true}); | ||
// isInfoEnabled replacement | ||
console.log("log.info() is:", log.info()) | ||
console.log('log.info() is:', log.info()) | ||
// `util.format`-based printf handling | ||
log.info("hi"); | ||
log.info("hi", "trent"); | ||
log.info("hi %s there", true); | ||
log.info('hi'); | ||
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", multiline:"one\ntwo\nthree"}, "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") | ||
console.log('\n') | ||
function Wuzzle(options) { | ||
this.log = options.log; | ||
this.log.info("creating a wuzzle") | ||
this.log.info('creating a wuzzle') | ||
} | ||
Wuzzle.prototype.woos = function () { | ||
this.log.warn("This wuzzle is woosey.") | ||
this.log.warn('This wuzzle is woosey.') | ||
} | ||
var wuzzle = new Wuzzle({log: log.child({component: "wuzzle"})}); | ||
var wuzzle = new Wuzzle({log: log.child({component: 'wuzzle'})}); | ||
wuzzle.woos(); | ||
log.info("done with the wuzzle") | ||
log.info('done with the wuzzle') |
@@ -40,9 +40,8 @@ // Play with setting levels. | ||
log.trace("no one should see this") | ||
log.debug("should see this once (on stdout)") | ||
log.info("should see this twice") | ||
log.trace('no one should see this') | ||
log.debug('should see this once (on stdout)') | ||
log.info('should see this twice') | ||
log.levels('stdout', INFO) | ||
log.debug("no one should see this either") | ||
log.debug('no one should see this either') | ||
log.level('trace') | ||
log.trace('should see this twice as 4th and 5th emitted log messages') | ||
var Logger = require('../lib/bunyan'); | ||
log = new Logger({ | ||
name: "amon", | ||
name: 'amon', | ||
streams: [ | ||
{ | ||
level: "info", | ||
level: 'info', | ||
stream: process.stdout, | ||
}, | ||
{ | ||
level: "error", | ||
path: "multi.log" | ||
level: 'error', | ||
path: 'multi.log' | ||
} | ||
@@ -17,5 +17,5 @@ ] | ||
log.debug("hi nobody on debug"); | ||
log.info("hi stdout on info"); | ||
log.error("hi both on error"); | ||
log.fatal("hi both on fatal"); | ||
log.debug('hi nobody on debug'); | ||
log.info('hi stdout on info'); | ||
log.error('hi both on error'); | ||
log.fatal('hi both on fatal'); |
@@ -7,3 +7,3 @@ // Example logging HTTP server request and response objects. | ||
var log = new Logger({ | ||
name: "myserver", | ||
name: 'myserver', | ||
serializers: { | ||
@@ -16,9 +16,9 @@ req: Logger.stdSerializers.req, | ||
var server = http.createServer(function (req, res) { | ||
log.info({req: req}, "start request"); // <-- this is the guy we're testing | ||
log.info({req: req}, 'start request'); // <-- this is the guy we're testing | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end('Hello World\n'); | ||
log.info({res: res}, "done response"); // <-- this is the guy we're testing | ||
log.info({res: res}, 'done response'); // <-- this is the guy we're testing | ||
}); | ||
server.listen(1337, "127.0.0.1", function () { | ||
log.info("server listening"); | ||
server.listen(1337, '127.0.0.1', function () { | ||
log.info('server listening'); | ||
var options = { | ||
@@ -38,3 +38,3 @@ port: 1337, | ||
}); | ||
req.write("hi from the client"); | ||
req.write('hi from the client'); | ||
req.end(); | ||
@@ -44,22 +44,24 @@ }); | ||
/* | ||
$ node server.js | ||
{"service":"myserver","hostname":"banana.local","level":3,"msg":"server listening","time":"2012-02-02T05:32:13.257Z","v":0} | ||
{"service":"myserver","hostname":"banana.local","req":{"method":"GET","url":"/path?q=1#anchor","headers":{"x-hi":"Mom","connection":"close"}},"level":3,"msg":"start request","time":"2012-02-02T05:32:13.260Z","v":0} | ||
{"service":"myserver","hostname":"banana.local","res":{"statusCode":200,"_hasBody":true,"_header":"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n","_trailer":""},"level":3,"msg":"done response","time":"2012-02-02T05:32:13.261Z","v":0} | ||
$ node server.js | ../bin/bunyan | ||
[2012-02-02T05:32:16.006Z] INFO: myserver on banana.local: server listening | ||
[2012-02-02T05:32:16.010Z] INFO: myserver on banana.local: start request | ||
GET /path?q=1#anchor | ||
x-hi: Mom | ||
connection: close | ||
[2012-02-02T05:32:16.011Z] INFO: myserver on banana.local: done response | ||
HTTP/1.1 200 OK | ||
Content-Type: text/plain | ||
Connection: close | ||
Transfer-Encoding: chunked | ||
(body) | ||
*/ | ||
/* BEGIN JSSTYLED */ | ||
/** | ||
* | ||
* $ node server.js | ||
* {"service":"myserver","hostname":"banana.local","level":3,"msg":"server listening","time":"2012-02-02T05:32:13.257Z","v":0} | ||
* {"service":"myserver","hostname":"banana.local","req":{"method":"GET","url":"/path?q=1#anchor","headers":{"x-hi":"Mom","connection":"close"}},"level":3,"msg":"start request","time":"2012-02-02T05:32:13.260Z","v":0} | ||
* {"service":"myserver","hostname":"banana.local","res":{"statusCode":200,"_hasBody":true,"_header":"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nConnection: close\r\nTransfer-Encoding: chunked\r\n\r\n","_trailer":""},"level":3,"msg":"done response","time":"2012-02-02T05:32:13.261Z","v":0} | ||
* | ||
* $ node server.js | ../bin/bunyan | ||
* [2012-02-02T05:32:16.006Z] INFO: myserver on banana.local: server listening | ||
* [2012-02-02T05:32:16.010Z] INFO: myserver on banana.local: start request | ||
* GET /path?q=1#anchor | ||
* x-hi: Mom | ||
* connection: close | ||
* [2012-02-02T05:32:16.011Z] INFO: myserver on banana.local: done response | ||
* HTTP/1.1 200 OK | ||
* Content-Type: text/plain | ||
* Connection: close | ||
* Transfer-Encoding: chunked | ||
* (body) | ||
* | ||
*/ | ||
/* END JSSTYLED */ |
@@ -6,8 +6,8 @@ // Show the usage of `src: true` config option to get log call source info in | ||
var log = new Logger({name: "src-example", src: true}); | ||
var log = new Logger({name: 'src-example', src: true}); | ||
log.info("one"); | ||
log.info("two"); | ||
log.info('one'); | ||
log.info('two'); | ||
function doSomeFoo() { | ||
log.info({foo:"bar"}, "three"); | ||
log.info({foo:'bar'}, 'three'); | ||
} | ||
@@ -18,11 +18,10 @@ doSomeFoo(); | ||
this.log = options.log; | ||
this.log.info("creating a wuzzle") | ||
this.log.info('creating a wuzzle') | ||
} | ||
Wuzzle.prototype.woos = function () { | ||
this.log.warn("This wuzzle is woosey.") | ||
this.log.warn('This wuzzle is woosey.') | ||
} | ||
var wuzzle = new Wuzzle({log: log.child({component: "wuzzle"})}); | ||
var wuzzle = new Wuzzle({log: log.child({component: 'wuzzle'})}); | ||
wuzzle.woos(); | ||
log.info("done with the wuzzle") | ||
log.info('done with the wuzzle') |
// See how bunyan behaves with an un-stringify-able object. | ||
var Logger = require("../lib/bunyan"); | ||
var Logger = require('../lib/bunyan'); | ||
var log = new Logger({src: true, name: "foo"}); | ||
var log = new Logger({src: true, name: 'foo'}); | ||
@@ -12,3 +12,2 @@ // Make a circular object (cannot be JSON-ified). | ||
log.info({obj: myobj}, "hi there"); // <--- here | ||
log.info({obj: myobj}, 'hi there'); // <--- here |
@@ -7,9 +7,9 @@ /* | ||
var VERSION = "0.7.0"; | ||
var VERSION = '0.8.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, | ||
// `0` is until I release a version '1.0.0' of node-bunyan. Thereafter, | ||
// starting with `1`, this will be incremented if there is any backward | ||
// incompatible change to the log record format. Details will be in | ||
// "CHANGES.md" (the change log). | ||
// 'CHANGES.md' (the change log). | ||
var LOG_VERSION = 0; | ||
@@ -29,2 +29,3 @@ | ||
var assert = require('assert'); | ||
var EventEmitter = require('events').EventEmitter; | ||
@@ -56,3 +57,3 @@ | ||
format = function format(f) { | ||
if (typeof f !== 'string') { | ||
if (typeof (f) !== 'string') { | ||
var objects = []; | ||
@@ -68,4 +69,5 @@ for (var i = 0; i < arguments.length; i++) { | ||
var len = args.length; | ||
var str = String(f).replace(formatRegExp, function(x) { | ||
if (i >= len) return x; | ||
var str = String(f).replace(formatRegExp, function (x) { | ||
if (i >= len) | ||
return x; | ||
switch (x) { | ||
@@ -81,3 +83,3 @@ case '%s': return String(args[i++]); | ||
for (var x = args[i]; i < len; x = args[++i]) { | ||
if (x === null || typeof x !== 'object') { | ||
if (x === null || typeof (x) !== 'object') { | ||
str += ' ' + x; | ||
@@ -103,3 +105,3 @@ } else { | ||
Error.captureStackTrace(this, getCaller3Info); | ||
Error.prepareStackTrace = function(_, stack) { | ||
Error.prepareStackTrace = function (_, stack) { | ||
var caller = stack[2]; | ||
@@ -164,3 +166,3 @@ obj.file = caller.getFileName(); | ||
function resolveLevel(nameOrNum) { | ||
var level = (typeof(nameOrNum) === 'string' | ||
var level = (typeof (nameOrNum) === 'string' | ||
? levelFromName[nameOrNum] | ||
@@ -182,9 +184,9 @@ : nameOrNum); | ||
* @param options {Object} See documentation for full details. At minimum | ||
* this must include a "name" string key. Configuration keys: | ||
* this must include a 'name' string key. Configuration keys: | ||
* - streams: specify the logger output streams. This is an array of | ||
* objects of the form: | ||
* { | ||
* "level": "info", // optional, "info" default | ||
* "stream": process.stdout, // "stream" or "path" is required | ||
* "closeOnExit": false // optional, default depends | ||
* 'level': 'info', // optional, "info" default | ||
* 'stream': process.stdout, // 'stream' or "path" is required | ||
* 'closeOnExit': false // optional, default depends | ||
* } | ||
@@ -238,3 +240,4 @@ * See README.md for full details. | ||
if ((options.stream || options.level) && options.streams) { | ||
throw new TypeError('cannot mix "streams" with "stream" or "level" options'); | ||
throw new TypeError( | ||
'cannot mix "streams" with "stream" or "level" options'); | ||
} | ||
@@ -244,7 +247,9 @@ if (options.streams && !Array.isArray(options.streams)) { | ||
} | ||
if (options.serializers && (typeof(options.serializers) !== 'object' | ||
|| Array.isArray(options.serializers))) { | ||
if (options.serializers && (typeof (options.serializers) !== 'object' || | ||
Array.isArray(options.serializers))) { | ||
throw new TypeError('invalid options.serializers: must be an object') | ||
} | ||
EventEmitter.call(this); | ||
// Fast path for simple child creation. | ||
@@ -303,5 +308,5 @@ if (parent && _childSimple) { | ||
if (s.stream) { | ||
s.type = "stream"; | ||
s.type = 'stream'; | ||
} else if (s.path) { | ||
s.type = "file" | ||
s.type = 'file' | ||
} | ||
@@ -320,3 +325,3 @@ } | ||
switch (s.type) { | ||
case "stream": | ||
case 'stream': | ||
if (!s.closeOnExit) { | ||
@@ -326,6 +331,9 @@ s.closeOnExit = false; | ||
break; | ||
case "file": | ||
case 'file': | ||
if (!s.stream) { | ||
s.stream = fs.createWriteStream(s.path, | ||
{flags: 'a', encoding: 'utf8'}); | ||
s.stream.on('error', function (err) { | ||
self.emit('error', err, s); | ||
}); | ||
if (!s.closeOnExit) { | ||
@@ -353,3 +361,3 @@ s.closeOnExit = true; | ||
var serializer = serializers[field]; | ||
if (typeof(serializer) !== "function") { | ||
if (typeof (serializer) !== 'function') { | ||
throw new TypeError(format( | ||
@@ -366,3 +374,3 @@ 'invalid serializer for "%s" field: must be a function', field)); | ||
addStream({ | ||
type: "stream", | ||
type: 'stream', | ||
stream: options.stream, | ||
@@ -376,3 +384,3 @@ closeOnExit: false, | ||
addStream({ | ||
type: "stream", | ||
type: 'stream', | ||
stream: process.stdout, | ||
@@ -389,3 +397,3 @@ closeOnExit: false, | ||
} | ||
xxx("Logger: ", self) | ||
xxx('Logger: ', self) | ||
@@ -417,3 +425,5 @@ // Fields. | ||
util.inherits(Logger, EventEmitter); | ||
/** | ||
@@ -423,9 +433,9 @@ * Create a child logger, typically to add a few log record fields. | ||
* This can be useful when passing a logger to a sub-component, e.g. a | ||
* "wuzzle" component of your service: | ||
* 'wuzzle' component of your service: | ||
* | ||
* var wuzzleLog = log.child({component: "wuzzle"}) | ||
* var wuzzleLog = log.child({component: 'wuzzle'}) | ||
* var wuzzle = new Wuzzle({..., log: wuzzleLog}) | ||
* | ||
* Then log records from the wuzzle code will have the same structure as | ||
* the app log, *plus the component="wuzzle" field*. | ||
* the app log, *plus the component='wuzzle' field*. | ||
* | ||
@@ -441,3 +451,3 @@ * @param options {Object} Optional. Set of options to apply to the child. | ||
* required for them. IOW, this is a fast path for frequent child | ||
* creation. See "tools/timechild.js" for numbers. | ||
* creation. See 'tools/timechild.js' for numbers. | ||
*/ | ||
@@ -449,23 +459,25 @@ Logger.prototype.child = function (options, simple) { | ||
///** | ||
// * Close this logger. | ||
// * | ||
// * This closes streams (that it owns, as per "endOnClose" attributes on | ||
// * streams), etc. Typically you **don't** need to bother calling this. | ||
// */ | ||
//Logger.prototype.close = function () { | ||
// if (this._closed) { | ||
// return; | ||
// } | ||
// if (!this._isSimpleChild) { | ||
// self.streams.forEach(function (s) { | ||
// if (s.endOnClose) { | ||
// xxx("closing stream s:", s); | ||
// s.stream.end(); | ||
// s.endOnClose = false; | ||
// } | ||
// }); | ||
// } | ||
// this._closed = true; | ||
//} | ||
/* BEGIN JSSTYLED */ | ||
/** | ||
* Close this logger. | ||
* | ||
* This closes streams (that it owns, as per 'endOnClose' attributes on | ||
* streams), etc. Typically you **don't** need to bother calling this. | ||
Logger.prototype.close = function () { | ||
if (this._closed) { | ||
return; | ||
} | ||
if (!this._isSimpleChild) { | ||
self.streams.forEach(function (s) { | ||
if (s.endOnClose) { | ||
xxx('closing stream s:', s); | ||
s.stream.end(); | ||
s.endOnClose = false; | ||
} | ||
}); | ||
} | ||
this._closed = true; | ||
} | ||
*/ | ||
/* END JSSTYLED */ | ||
@@ -482,3 +494,3 @@ | ||
* log.level(INFO) // set all streams to level INFO | ||
* log.level("info") // can use "info" et al aliases | ||
* log.level('info') // can use 'info' et al aliases | ||
*/ | ||
@@ -507,8 +519,8 @@ Logger.prototype.level = function level(value) { | ||
* log.levels(0) -> TRACE // level of stream at index 0 | ||
* log.levels("foo") // level of stream with name "foo" | ||
* log.levels('foo') // level of stream with name 'foo' | ||
* | ||
* Set Usage: | ||
* log.levels(0, INFO) // set level of stream 0 to INFO | ||
* log.levels(0, "info") // can use "info" et al aliases | ||
* log.levels("foo", WARN) // set stream named "foo" to WARN | ||
* log.levels(0, 'info') // can use 'info' et al aliases | ||
* log.levels('foo', WARN) // set stream named 'foo' to WARN | ||
* | ||
@@ -520,3 +532,3 @@ * Stream names: When streams are defined, they can optionally be given | ||
* { | ||
* name: 'foo', // <--- proposed new option, yucky controlling uniqueness | ||
* name: 'foo', | ||
* path: '/var/log/my-service/foo.log' | ||
@@ -528,3 +540,3 @@ * level: 'trace' | ||
* @param name {String|Number} The stream index or name. | ||
* @param value {Number|String} The level value (INFO) or alias ("info"). | ||
* @param value {Number|String} The level value (INFO) or alias ('info'). | ||
* If not given, this is a 'get' operation. | ||
@@ -536,6 +548,7 @@ * @throws {Error} If there is no stream with the given name. | ||
assert.equal(value, undefined); | ||
return this.streams.map(function (s) { return s.level }); | ||
return this.streams.map( | ||
function (s) { return s.level }); | ||
} | ||
var stream; | ||
if (typeof name === 'number') { | ||
if (typeof (name) === 'number') { | ||
stream = this.streams[name]; | ||
@@ -585,3 +598,3 @@ if (stream === undefined) { | ||
applyKeys = {}; | ||
for (var i=0; i < keys.length; i++) { | ||
for (var i = 0; i < keys.length; i++) { | ||
applyKeys[keys[i]] = true; | ||
@@ -645,3 +658,3 @@ } | ||
} | ||
xxx("Record:", rec) | ||
xxx('Record:', rec) | ||
obj.msg = format.apply(this, rec[3]); | ||
@@ -663,4 +676,4 @@ if (!obj.time) { | ||
var src = ((obj.src && obj.src.file) ? obj.src : getCaller3Info()); | ||
var emsg = format("bunyan: ERROR: could not stringify log record from " | ||
+ "%s:%d: %s", src.file, src.line, e); | ||
var emsg = format('bunyan: ERROR: could not stringify log record from ' | ||
+ '%s:%d: %s', src.file, src.line, e); | ||
var eobj = objCopy(rec[0]); | ||
@@ -679,3 +692,3 @@ eobj.bunyanMsg = emsg; | ||
this.streams.forEach(function(s) { | ||
this.streams.forEach(function (s) { | ||
if (s.level <= level) { | ||
@@ -718,3 +731,3 @@ xxx('writing log rec "%s" to "%s" stream (%d <= %d)', obj.msg, s.type, | ||
} | ||
} else if (typeof arguments[0] === 'string') { // `log.trace(msg, ...)` | ||
} else if (typeof (arguments[0]) === 'string') { // `log.trace(msg, ...)` | ||
fields = null; | ||
@@ -758,3 +771,3 @@ msgArgs = Array.prototype.slice.call(arguments); | ||
} | ||
} else if (typeof arguments[0] === 'string') { // `log.debug(msg, ...)` | ||
} else if (typeof (arguments[0]) === 'string') { // `log.debug(msg, ...)` | ||
fields = null; | ||
@@ -798,3 +811,3 @@ msgArgs = Array.prototype.slice.call(arguments); | ||
} | ||
} else if (typeof arguments[0] === 'string') { // `log.info(msg, ...)` | ||
} else if (typeof (arguments[0]) === 'string') { // `log.info(msg, ...)` | ||
fields = null; | ||
@@ -838,3 +851,3 @@ msgArgs = Array.prototype.slice.call(arguments); | ||
} | ||
} else if (typeof arguments[0] === 'string') { // `log.warn(msg, ...)` | ||
} else if (typeof (arguments[0]) === 'string') { // `log.warn(msg, ...)` | ||
fields = null; | ||
@@ -878,3 +891,3 @@ msgArgs = Array.prototype.slice.call(arguments); | ||
} | ||
} else if (typeof arguments[0] === 'string') { // `log.error(msg, ...)` | ||
} else if (typeof (arguments[0]) === 'string') { // `log.error(msg, ...)` | ||
fields = null; | ||
@@ -918,3 +931,3 @@ msgArgs = Array.prototype.slice.call(arguments); | ||
} | ||
} else if (typeof arguments[0] === 'string') { // `log.fatal(msg, ...)` | ||
} else if (typeof (arguments[0]) === 'string') { // `log.fatal(msg, ...)` | ||
fields = null; | ||
@@ -921,0 +934,0 @@ msgArgs = Array.prototype.slice.call(arguments); |
{ | ||
"name": "bunyan", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "a JSON Logger library for node.js servers", | ||
@@ -5,0 +5,0 @@ "author": "Trent Mick <trentm@gmail.com> (http://trentm.com)", |
@@ -446,2 +446,3 @@ Bunyan is a simple and fast a JSON Logger for node.js services (and a `bunyan` | ||
- Bunyan re-emits error events if the file cannot be opened successfully. | ||
@@ -448,0 +449,0 @@ |
@@ -60,3 +60,5 @@ /* | ||
t.error(err) | ||
t.equal(stdout, '[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: My message\n'); | ||
t.equal(stdout, | ||
'[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: ' | ||
+ 'My message\n'); | ||
t.end(); | ||
@@ -69,3 +71,5 @@ }); | ||
t.error(err) | ||
t.equal(stdout, '[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: My message\n'); | ||
t.equal(stdout, | ||
'[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: ' | ||
+ 'My message\n'); | ||
t.end(); | ||
@@ -78,3 +82,5 @@ } | ||
t.error(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'); | ||
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'); | ||
t.end(); | ||
@@ -87,3 +93,5 @@ }); | ||
t.error(err) | ||
t.equal(stdout, '[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: My message (extra=field)\n'); | ||
t.equal(stdout, | ||
'[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: ' | ||
+ 'My message (extra=field)\n'); | ||
t.end(); | ||
@@ -93,5 +101,9 @@ }); | ||
test('extrafield.log with color', function (t) { | ||
exec(BUNYAN + ' --color corpus/extrafield.log', function (err, stdout, stderr) { | ||
exec(BUNYAN + ' --color corpus/extrafield.log', | ||
function (err, stdout, stderr) { | ||
t.error(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'); | ||
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'); | ||
t.end(); | ||
@@ -130,3 +142,5 @@ }); | ||
t.equal(err.code, 2) | ||
t.equal(stdout, '[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: My message\n'); | ||
t.equal(stdout, | ||
'[2012-02-08T22:56:52.856Z] INFO: myservice/123 on example.com: ' | ||
+ 'My message\n'); | ||
// Note: node v0.6.10: | ||
@@ -137,3 +151,5 @@ // ENOENT, no such file or directory 'asdf.log' | ||
// Somewhat annoying change. | ||
t.equal(stderr, "bunyan: ENOENT, open 'doesnotexist1.log'\nbunyan: ENOENT, open 'doesnotexist2.log'\n"); | ||
t.equal(stderr, | ||
'bunyan: ENOENT, open \'doesnotexist1.log\'\nbunyan: ENOENT, ' | ||
+ 'open \'doesnotexist2.log\'\n'); | ||
t.end(); | ||
@@ -140,0 +156,0 @@ } |
@@ -41,8 +41,14 @@ /* | ||
t.throws(function () { new Logger(options); }, | ||
{name: 'TypeError', message: 'invalid options.serializers: must be an object'}, | ||
{ | ||
name: 'TypeError', | ||
message: 'invalid options.serializers: must be an object' | ||
}, | ||
'"serializers" cannot be a string'); | ||
options = {name: 'foo', serializers: [1,2,3]}; | ||
options = {name: 'foo', serializers: [1, 2, 3]}; | ||
t.throws(function () { new Logger(options); }, | ||
{name: 'TypeError', message: 'invalid options.serializers: must be an object'}, | ||
{ | ||
name: 'TypeError', | ||
message: 'invalid options.serializers: must be an object' | ||
}, | ||
'"serializers" cannot be an array'); | ||
@@ -82,8 +88,14 @@ | ||
t.throws(function () { bunyan.createLogger(options); }, | ||
{name: 'TypeError', message: 'invalid options.serializers: must be an object'}, | ||
{ | ||
name: 'TypeError', | ||
message: 'invalid options.serializers: must be an object' | ||
}, | ||
'"serializers" cannot be a string'); | ||
options = {name: 'foo', serializers: [1,2,3]}; | ||
options = {name: 'foo', serializers: [1, 2, 3]}; | ||
t.throws(function () { bunyan.createLogger(options); }, | ||
{name: 'TypeError', message: 'invalid options.serializers: must be an object'}, | ||
{ | ||
name: 'TypeError', | ||
message: 'invalid options.serializers: must be an object' | ||
}, | ||
'"serializers" cannot be an array'); | ||
@@ -105,3 +117,6 @@ | ||
t.throws(function () { log.child({name: 'foo'}); }, | ||
{name: 'TypeError', message: 'invalid options.name: child cannot set logger name'}, | ||
{ | ||
name: 'TypeError', | ||
message: 'invalid options.name: child cannot set logger name' | ||
}, | ||
'child cannot change name'); | ||
@@ -123,10 +138,16 @@ | ||
options = {serializers: "a string"}; | ||
options = {serializers: 'a string'}; | ||
t.throws(function () { log.child(options); }, | ||
{name: 'TypeError', message: 'invalid options.serializers: must be an object'}, | ||
{ | ||
name: 'TypeError', | ||
message: 'invalid options.serializers: must be an object' | ||
}, | ||
'"serializers" cannot be a string'); | ||
options = {serializers: [1,2,3]}; | ||
options = {serializers: [1, 2, 3]}; | ||
t.throws(function () { log.child(options); }, | ||
{name: 'TypeError', message: 'invalid options.serializers: must be an object'}, | ||
{ | ||
name: 'TypeError', | ||
message: 'invalid options.serializers: must be an object' | ||
}, | ||
'"serializers" cannot be an array'); | ||
@@ -133,0 +154,0 @@ |
@@ -1,2 +0,1 @@ | ||
- finish jsstyle work | ||
- [Yuonong] buffered writes to increase speed: | ||
@@ -3,0 +2,0 @@ - I'd start with a tools/timeoutput.js for some numbers to compare |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1598
469
145144
2