Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix raw #727

Merged
merged 2 commits into from
Oct 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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