Comparing version 0.14.4 to 0.14.5
# bunyan Changelog | ||
## bunyan 0.14.5 | ||
- Fix a bug in the long-stack-trace error serialization added in 0.14.4. The | ||
symptom: | ||
bunyan@0.14.4: .../node_modules/bunyan/lib/bunyan.js:1002 | ||
var ret = ex.stack || ex.toString(); | ||
^ | ||
TypeError: Cannot read property 'stack' of undefined | ||
at getFullErrorStack (.../node_modules/bunyan/lib/bunyan.js:1002:15) | ||
... | ||
## bunyan 0.14.4 | ||
@@ -4,0 +17,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
var VERSION = '0.14.4'; | ||
var VERSION = '0.14.5'; | ||
@@ -1004,4 +1004,8 @@ // Bunyan log format version. This becomes the 'v' field on all log records. | ||
var ret = ex.stack || ex.toString(); | ||
if (ex.cause && typeof(ex.cause) === 'function') | ||
ret += '\nCaused by: ' + getFullErrorStack(ex.cause()); | ||
if (ex.cause && typeof(ex.cause) === 'function') { | ||
var cex = ex.cause(); | ||
if (cex) { | ||
ret += '\nCaused by: ' + getFullErrorStack(cex); | ||
} | ||
} | ||
return (ret); | ||
@@ -1008,0 +1012,0 @@ } |
{ | ||
"name": "bunyan", | ||
"version": "0.14.4", | ||
"version": "0.14.5", | ||
"description": "a JSON Logger library for node.js services", | ||
@@ -20,3 +20,4 @@ "author": "Trent Mick <trentm@gmail.com> (http://trentm.com)", | ||
"tap": "0.2.0", | ||
"ben": "0.0.0" | ||
"ben": "0.0.0", | ||
"verror": "1.3.3" | ||
}, | ||
@@ -23,0 +24,0 @@ |
@@ -8,6 +8,8 @@ /* | ||
var test = require('tap').test; | ||
var bunyan = require('../lib/bunyan'); | ||
var http = require('http'); | ||
var bunyan = require('../lib/bunyan'); | ||
var verror = require('verror'); | ||
function CapturingStream(recs) { | ||
@@ -172,1 +174,83 @@ this.recs = recs; | ||
}); | ||
test('err serializer: long stack', function (t) { | ||
var records = []; | ||
var log = bunyan.createLogger({ | ||
name: 'serializer-test', | ||
streams: [{ | ||
stream: new CapturingStream(records), | ||
type: 'raw' | ||
}], | ||
serializers: { | ||
err: bunyan.stdSerializers.err | ||
} | ||
}); | ||
var topErr, midErr, bottomErr; | ||
// Just a VError. | ||
topErr = new verror.VError('top err'); | ||
log.info(topErr, 'the error'); | ||
var lastRecord = records[records.length-1]; | ||
t.equal(lastRecord.err.message, topErr.message); | ||
t.equal(lastRecord.err.name, topErr.name); | ||
t.equal(lastRecord.err.stack, topErr.stack); | ||
// Just a WError. | ||
topErr = new verror.WError('top err'); | ||
log.info(topErr, 'the error'); | ||
var lastRecord = records[records.length-1]; | ||
t.equal(lastRecord.err.message, topErr.message); | ||
t.equal(lastRecord.err.name, topErr.name); | ||
t.equal(lastRecord.err.stack, topErr.stack); | ||
// WError <- TypeError | ||
bottomErr = new TypeError('bottom err'); | ||
topErr = new verror.WError(bottomErr, 'top err'); | ||
log.info(topErr, 'the error'); | ||
var lastRecord = records[records.length-1]; | ||
t.equal(lastRecord.err.message, topErr.message); | ||
t.equal(lastRecord.err.name, topErr.name); | ||
var expectedStack = topErr.stack + '\nCaused by: ' + bottomErr.stack; | ||
t.equal(lastRecord.err.stack, expectedStack); | ||
// WError <- WError | ||
bottomErr = new verror.WError('bottom err'); | ||
topErr = new verror.WError(bottomErr, 'top err'); | ||
log.info(topErr, 'the error'); | ||
var lastRecord = records[records.length-1]; | ||
t.equal(lastRecord.err.message, topErr.message); | ||
t.equal(lastRecord.err.name, topErr.name); | ||
var expectedStack = topErr.stack + '\nCaused by: ' + bottomErr.stack; | ||
t.equal(lastRecord.err.stack, expectedStack); | ||
// WError <- WError <- TypeError | ||
bottomErr = new TypeError('bottom err'); | ||
midErr = new verror.WError(bottomErr, 'mid err'); | ||
topErr = new verror.WError(midErr, 'top err'); | ||
log.info(topErr, 'the error'); | ||
var lastRecord = records[records.length-1]; | ||
t.equal(lastRecord.err.message, topErr.message); | ||
t.equal(lastRecord.err.name, topErr.name); | ||
var expectedStack = (topErr.stack | ||
+ '\nCaused by: ' + midErr.stack | ||
+ '\nCaused by: ' + bottomErr.stack); | ||
t.equal(lastRecord.err.stack, expectedStack); | ||
// WError <- WError <- WError | ||
bottomErr = new verror.WError('bottom err'); | ||
midErr = new verror.WError(bottomErr, 'mid err'); | ||
topErr = new verror.WError(midErr, 'top err'); | ||
log.info(topErr, 'the error'); | ||
var lastRecord = records[records.length-1]; | ||
t.equal(lastRecord.err.message, topErr.message); | ||
t.equal(lastRecord.err.name, topErr.name); | ||
var expectedStack = (topErr.stack | ||
+ '\nCaused by: ' + midErr.stack | ||
+ '\nCaused by: ' + bottomErr.stack); | ||
t.equal(lastRecord.err.stack, expectedStack); | ||
t.end(); | ||
}); |
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
238160
47
2454
3