Skip to content

Commit

Permalink
Revert "Use common.format inside every log method"
Browse files Browse the repository at this point in the history
This reverts commit acc2444.
  • Loading branch information
fb55 committed Jul 27, 2012
1 parent b8cf35c commit d546f75
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 44 deletions.
22 changes: 10 additions & 12 deletions lib/winston/logger.js
Expand Up @@ -120,25 +120,23 @@ Logger.prototype.extend = function (target) {
// #### @callback {function} Continuation to respond to when complete. // #### @callback {function} Continuation to respond to when complete.
// Core logging method exposed to Winston. Metadata is optional. // Core logging method exposed to Winston. Metadata is optional.
// //
Logger.prototype.log = function (level) { Logger.prototype.log = function (level, msg) {
var self = this, var self = this,
args = Array.prototype.slice.call(arguments, 1),
msg = common.format(args),
callback, callback,
meta; meta;


if (args.length === 1) { if (arguments.length === 3) {
if (typeof args[0] === 'function') { if (typeof arguments[2] === 'function') {
meta = {}; meta = {};
callback = args[0]; callback = arguments[2];
} }
else if (typeof args[0] === 'object') { else if (typeof arguments[2] === 'object') {
meta = args[0]; meta = arguments[2];
} }
} }
else if (args.length === 2) { else if (arguments.length === 4) {
meta = args[0]; meta = arguments[2];
callback = args[1]; callback = arguments[3];
} }


// If we should pad for levels, do so // If we should pad for levels, do so
Expand All @@ -152,7 +150,7 @@ Logger.prototype.log = function (level) {
} }
else if (self.emitErrs) { else if (self.emitErrs) {
self.emit('error', err); self.emit('error', err);
} };
} }


if (this.transports.length === 0) { if (this.transports.length === 0) {
Expand Down
12 changes: 4 additions & 8 deletions lib/winston/transports/console.js
Expand Up @@ -53,18 +53,14 @@ Console.prototype.name = 'console';
// #### @callback {function} Continuation to respond to when complete. // #### @callback {function} Continuation to respond to when complete.
// Core logging method exposed to Winston. Metadata is optional. // Core logging method exposed to Winston. Metadata is optional.
// //
Console.prototype.log = function (level) { Console.prototype.log = function (level, msg, meta, callback) {
var self = this,
args = Array.prototype.slice.call(arguments, 1),
msg = common.format(args),
meta = args[0],
callback = args[1],
output;

if (this.silent) { if (this.silent) {
return callback(null, true); return callback(null, true);
} }


var self = this,
output;

output = common.log({ output = common.log({
colorize: this.colorize, colorize: this.colorize,
json: this.json, json: this.json,
Expand Down
13 changes: 4 additions & 9 deletions lib/winston/transports/file.js
Expand Up @@ -97,19 +97,14 @@ File.prototype.name = 'file';
// #### @callback {function} Continuation to respond to when complete. // #### @callback {function} Continuation to respond to when complete.
// Core logging method exposed to Winston. Metadata is optional. // Core logging method exposed to Winston. Metadata is optional.
// //
File.prototype.log = function (level) { File.prototype.log = function (level, msg, meta, callback) {
var self = this,
args = Array.prototype.slice.call(arguments, 1),
msg = common.format(args),
meta = args[0],
callback = args[1],
output;

if (this.silent) { if (this.silent) {
return callback(null, true); return callback(null, true);
} }


output = common.log({ var self = this;

var output = common.log({
level: level, level: level,
message: msg, message: msg,
meta: meta, meta: meta,
Expand Down
9 changes: 2 additions & 7 deletions lib/winston/transports/http.js
@@ -1,6 +1,5 @@
var util = require('util'), var util = require('util'),
winston = require('../../winston'), winston = require('../../winston'),
common = require('../common'),
request = require('request'), request = require('request'),
Stream = require('stream').Stream; Stream = require('stream').Stream;


Expand Down Expand Up @@ -70,12 +69,8 @@ Http.prototype._request = function (options, callback) {
// #### @callback {function} Continuation to respond to when complete. // #### @callback {function} Continuation to respond to when complete.
// Core logging method exposed to Winston. Metadata is optional. // Core logging method exposed to Winston. Metadata is optional.
// //
Http.prototype.log = function (level) { Http.prototype.log = function (level, msg, meta, callback) {
var self = this, var self = this;
args = Array.prototype.slice.call(arguments, 1),
msg = common.format(args),
meta = args[0],
callback = args[1];


if (typeof meta === 'function') { if (typeof meta === 'function') {
callback = meta; callback = meta;
Expand Down
11 changes: 3 additions & 8 deletions lib/winston/transports/webhook.js
Expand Up @@ -62,18 +62,13 @@ Webhook.prototype.name = 'webhook';
// #### @callback {function} Continuation to respond to when complete. // #### @callback {function} Continuation to respond to when complete.
// Core logging method exposed to Winston. Metadata is optional. // Core logging method exposed to Winston. Metadata is optional.
// //
Webhook.prototype.log = function (level) { Webhook.prototype.log = function (level, msg, meta, callback) {
var self = this,
args = Array.prototype.slice.call(arguments, 1),
msg = common.format(args),
meta = args[0],
callback = args[1];

if (this.silent) { if (this.silent) {
return callback(null, true); return callback(null, true);
} }


var meta = cycle.decycle(meta), var self = this,
meta = cycle.decycle(meta),
message = common.clone(meta), message = common.clone(meta),
options, options,
req; req;
Expand Down

0 comments on commit d546f75

Please sign in to comment.