Permalink
Browse files

Use common.format inside every log method

  • Loading branch information...
1 parent 3998d19 commit acc244423e7ebd5d122e93e61d68f060389652d1 @fb55 fb55 committed Jul 23, 2012
View
22 lib/winston/logger.js
@@ -120,23 +120,25 @@ 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, msg) {
+Logger.prototype.log = function (level) {
var self = this,
+ args = Array.prototype.slice.call(arguments, 1),
+ msg = common.format(args),
callback,
meta;
- if (arguments.length === 3) {
- if (typeof arguments[2] === 'function') {
+ if (args.length === 1) {
+ if (typeof args[0] === 'function') {
meta = {};
- callback = arguments[2];
+ callback = args[0];
}
- else if (typeof arguments[2] === 'object') {
- meta = arguments[2];
+ else if (typeof args[0] === 'object') {
+ meta = args[0];
}
}
- else if (arguments.length === 4) {
- meta = arguments[2];
- callback = arguments[3];
+ else if (args.length === 2) {
+ meta = args[0];
+ callback = args[1];
}
// If we should pad for levels, do so
@@ -150,7 +152,7 @@ Logger.prototype.log = function (level, msg) {
}
else if (self.emitErrs) {
self.emit('error', err);
- };
+ }
}
if (this.transports.length === 0) {
View
12 lib/winston/transports/console.js
@@ -53,14 +53,18 @@ 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, msg, meta, callback) {
+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;
+
if (this.silent) {
return callback(null, true);
}
- var self = this,
- output;
-
output = common.log({
colorize: this.colorize,
json: this.json,
View
13 lib/winston/transports/file.js
@@ -97,14 +97,19 @@ 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, msg, meta, callback) {
+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;
+
if (this.silent) {
return callback(null, true);
}
- var self = this;
-
- var output = common.log({
+ output = common.log({
level: level,
message: msg,
meta: meta,
View
9 lib/winston/transports/http.js
@@ -1,5 +1,6 @@
var util = require('util'),
winston = require('../../winston'),
+ common = require('../common'),
request = require('request'),
Stream = require('stream').Stream;
@@ -69,8 +70,12 @@ 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, msg, meta, callback) {
- var self = this;
+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];
if (typeof meta === 'function') {
callback = meta;
View
11 lib/winston/transports/webhook.js
@@ -62,13 +62,18 @@ 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, msg, meta, callback) {
+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];
+
if (this.silent) {
return callback(null, true);
}
- var self = this,
- meta = cycle.decycle(meta),
+ var meta = cycle.decycle(meta),
message = common.clone(meta),
options,
req;

0 comments on commit acc2444

Please sign in to comment.