Skip to content

Commit

Permalink
fix show levels property for console transport
Browse files Browse the repository at this point in the history
  • Loading branch information
james.yang authored and indexzero committed Feb 5, 2015
1 parent 68a5dd7 commit 72bff04
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/winston/transports/console.js
Expand Up @@ -73,6 +73,7 @@ Console.prototype.log = function (level, msg, meta, callback) {
meta: meta,
stringify: this.stringify,
timestamp: this.timestamp,
showLevel: this.showLevel,
prettyPrint: this.prettyPrint,
raw: this.raw,
label: this.label,
Expand Down
31 changes: 30 additions & 1 deletion test/transports/console-test.js
Expand Up @@ -10,13 +10,42 @@ var path = require('path'),
vows = require('vows'),
assert = require('assert'),
winston = require('../../lib/winston'),
helpers = require('../helpers');
helpers = require('../helpers'),
stdMocks = require('std-mocks');

var npmTransport = new (winston.transports.Console)(),
syslogTransport = new (winston.transports.Console)({ levels: winston.config.syslog.levels });

vows.describe('winston/transports/console').addBatch({
"An instance of the Console Transport": {
"with showLevel on": {
topic : function() {
npmTransport.showLevel = true;
stdMocks.use();
npmTransport.log('info', '');
},
"should have level prepended": function () {
stdMocks.restore();
var output = stdMocks.flush(),
line = output.stdout[0];

assert.equal(line, 'info: \n');
}
},
"with showLevel on": {
topic : function() {
npmTransport.showLevel = false;
stdMocks.use();
npmTransport.log('info', '');
},
"should not have level prepended": function () {
stdMocks.restore();
var output = stdMocks.flush(),
line = output.stdout[0];

assert.equal(line, '\n');
}
},
"with npm levels": {
"should have the proper methods defined": function () {
helpers.assertConsole(npmTransport);
Expand Down

0 comments on commit 72bff04

Please sign in to comment.