diff --git a/lib/winston/transports/console.js b/lib/winston/transports/console.js index cd9f11127..d6bbd00ec 100644 --- a/lib/winston/transports/console.js +++ b/lib/winston/transports/console.js @@ -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, diff --git a/test/transports/console-test.js b/test/transports/console-test.js index 07f5a6ea6..317ba6001 100644 --- a/test/transports/console-test.js +++ b/test/transports/console-test.js @@ -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);