Skip to content

Commit

Permalink
Merge pull request #727 from winstonjs/fix-raw
Browse files Browse the repository at this point in the history
Fix raw
  • Loading branch information
jcrugzz committed Oct 18, 2015
2 parents fb12093 + 4450bf9 commit e863a8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/winston/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@ exports.log = function (options) {
}
output = exports.clone(meta) || {};
output.level = options.level;
output.message = options.message.stripColors;
//
// Remark (jcrugzz): This used to be output.message = options.message.stripColors.
// I do not know why this is, it does not make sense but im handling that
// case here as well as handling the case that does make sense which is to
// make the `output.message = options.message`
//
output.message = options.message.stripColors
? options.message.stripColors
: options.message;

return JSON.stringify(output);
}

Expand Down
15 changes: 15 additions & 0 deletions test/transports/console-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var npmTransport = new (winston.transports.Console)(),
syslogTransport = new (winston.transports.Console)({ levels: winston.config.syslog.levels }),
alignTransport = new (winston.transports.Console)({ showLevel: true, align: true }),
defaultTransport = new (winston.transports.Console)(),
rawTransport = new (winston.transports.Console)({ level: 'verbose', raw: true }),
debugStdoutTransport = new (winston.transports.Console)({ debugStdout: true }),
stderrLevelsTransport = new (winston.transports.Console)({ stderrLevels: ['info', 'warn'] }),
customLevels = {
Expand All @@ -34,6 +35,7 @@ var npmTransport = new (winston.transports.Console)(),

vows.describe('winston/transports/console').addBatch({
"An instance of the Console Transport": {

"with showLevel on": {
topic : function() {
npmTransport.showLevel = true;
Expand Down Expand Up @@ -110,6 +112,19 @@ vows.describe('winston/transports/console').addBatch({
assert.equal(line, 'info: \n');
}
}
}).addBatch({
'An instance of a raw Console transport': {
'logging to stdout': {
topic: function () {
stdMocks.use();
rawTransport.log('verbose', 'hello there');
}, 'should output json with message property': function () {
stdMocks.restore();
var output = stdMocks.flush();
assert.ok(output.stdout[0].indexOf('"message":"hello there"') > -1);
}
}
}
}).addBatch({
"An instance of the Console Transport with no options": {
"should set stderrLevels to 'error' and 'debug' by default": helpers.assertStderrLevels(
Expand Down

0 comments on commit e863a8f

Please sign in to comment.