diff --git a/lib/winston/logger.js b/lib/winston/logger.js index 58a64c221..49e6d4c29 100644 --- a/lib/winston/logger.js +++ b/lib/winston/logger.js @@ -120,25 +120,23 @@ Logger.prototype.extend = function (target) { // #### @callback {function} Continuation to respond to when complete. // Core logging method exposed to Winston. Metadata is optional. // -Logger.prototype.log = function (level) { +Logger.prototype.log = function (level, msg) { var self = this, - args = Array.prototype.slice.call(arguments, 1), - msg = common.format(args), callback, meta; - if (args.length === 1) { - if (typeof args[0] === 'function') { + if (arguments.length === 3) { + if (typeof arguments[2] === 'function') { meta = {}; - callback = args[0]; + callback = arguments[2]; } - else if (typeof args[0] === 'object') { - meta = args[0]; + else if (typeof arguments[2] === 'object') { + meta = arguments[2]; } } - else if (args.length === 2) { - meta = args[0]; - callback = args[1]; + else if (arguments.length === 4) { + meta = arguments[2]; + callback = arguments[3]; } // If we should pad for levels, do so @@ -152,7 +150,7 @@ Logger.prototype.log = function (level) { } else if (self.emitErrs) { self.emit('error', err); - } + }; } if (this.transports.length === 0) { diff --git a/lib/winston/transports/console.js b/lib/winston/transports/console.js index 2b8d88c3b..43cdee3b7 100644 --- a/lib/winston/transports/console.js +++ b/lib/winston/transports/console.js @@ -53,18 +53,14 @@ Console.prototype.name = 'console'; // #### @callback {function} Continuation to respond to when complete. // Core logging method exposed to Winston. Metadata is optional. // -Console.prototype.log = function (level) { - var self = this, - args = Array.prototype.slice.call(arguments, 1), - msg = common.format(args), - meta = args[0], - callback = args[1], - output; - +Console.prototype.log = function (level, msg, meta, callback) { if (this.silent) { return callback(null, true); } + var self = this, + output; + output = common.log({ colorize: this.colorize, json: this.json, diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index 63261f0b4..7080e2872 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -97,19 +97,14 @@ File.prototype.name = 'file'; // #### @callback {function} Continuation to respond to when complete. // Core logging method exposed to Winston. Metadata is optional. // -File.prototype.log = function (level) { - var self = this, - args = Array.prototype.slice.call(arguments, 1), - msg = common.format(args), - meta = args[0], - callback = args[1], - output; - +File.prototype.log = function (level, msg, meta, callback) { if (this.silent) { return callback(null, true); } - output = common.log({ + var self = this; + + var output = common.log({ level: level, message: msg, meta: meta, diff --git a/lib/winston/transports/http.js b/lib/winston/transports/http.js index e46a8805b..9b9c61dd1 100644 --- a/lib/winston/transports/http.js +++ b/lib/winston/transports/http.js @@ -1,6 +1,5 @@ var util = require('util'), winston = require('../../winston'), - common = require('../common'), request = require('request'), Stream = require('stream').Stream; @@ -70,12 +69,8 @@ Http.prototype._request = function (options, callback) { // #### @callback {function} Continuation to respond to when complete. // Core logging method exposed to Winston. Metadata is optional. // -Http.prototype.log = function (level) { - var self = this, - args = Array.prototype.slice.call(arguments, 1), - msg = common.format(args), - meta = args[0], - callback = args[1]; +Http.prototype.log = function (level, msg, meta, callback) { + var self = this; if (typeof meta === 'function') { callback = meta; diff --git a/lib/winston/transports/webhook.js b/lib/winston/transports/webhook.js index 6512e4a50..34b4a35aa 100644 --- a/lib/winston/transports/webhook.js +++ b/lib/winston/transports/webhook.js @@ -62,18 +62,13 @@ Webhook.prototype.name = 'webhook'; // #### @callback {function} Continuation to respond to when complete. // Core logging method exposed to Winston. Metadata is optional. // -Webhook.prototype.log = function (level) { - var self = this, - args = Array.prototype.slice.call(arguments, 1), - msg = common.format(args), - meta = args[0], - callback = args[1]; - +Webhook.prototype.log = function (level, msg, meta, callback) { if (this.silent) { return callback(null, true); } - var meta = cycle.decycle(meta), + var self = this, + meta = cycle.decycle(meta), message = common.clone(meta), options, req;