Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test humanReadableUnhandledException flag
- Loading branch information
1 parent
bcd8b0d
commit 30d89fa
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* custom-pretty-print-test.js: Test function as pretty print option. | ||
* | ||
* (C) 2015 Alberto Pose | ||
* MIT LICENSE | ||
* | ||
*/ | ||
|
||
var assert = require('assert'), | ||
vows = require('vows'), | ||
winston = require('../lib/winston'); | ||
|
||
vows.describe('winston/transport/humanReadableUnhandledException').addBatch({ | ||
"When humanReadableUnhandledException option is used": { | ||
"with memory transport": { | ||
topic: function () { | ||
var transport = new (winston.transports.Memory)({humanReadableUnhandledException: true}); | ||
return this.callback(null, transport); | ||
}, | ||
"should log the stack trace in a human readable form": function (_, transport) { | ||
var meta = { | ||
date: 'dummy date', | ||
process: 'dummy', | ||
os: 'dummy', | ||
trace: 'dummy', | ||
stack: ['first line','second line'] | ||
}; | ||
|
||
transport.log('info', 'stack:', meta, function (_, logged) { | ||
assert.ok(logged); | ||
assert.equal(1, transport.writeOutput.length); | ||
|
||
var msg = transport.writeOutput[0]; | ||
assert.notEqual(-1, msg.indexOf('stack: date=dummy date, process=dummy, os=dummy\n')); | ||
assert.notEqual(-1, msg.indexOf(meta.stack[0] + '\n')); | ||
assert.notEqual(-1, msg.indexOf(',' + meta.stack[1])); | ||
}); | ||
} | ||
} | ||
} | ||
}).export(module); |