Skip to content

Commit

Permalink
[refactor minor] Move lib/winston/utils.js to lib/winston/internal.js
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Jul 18, 2011
1 parent fc00cfd commit eb5f9e5
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
20 changes: 9 additions & 11 deletions lib/winston.js
Expand Up @@ -6,8 +6,6 @@
*
*/

require.paths.unshift(require('path').join(__dirname));

var winston = exports;

//
Expand All @@ -18,7 +16,7 @@ require('pkginfo')(module, 'version');
//
// Include transports defined by default by winston
//
winston.transports = require('winston/transports');
winston.transports = require('./winston/transports');

//
// function findTransport (transport)
Expand All @@ -32,11 +30,11 @@ winston.findTransport = function (transport) {
return existing.length > 0 ? existing[0].toLowerCase() : null;
};

var utils = require('winston/utils');
winston.hash = utils.hash;
winston.clone = utils.clone;
winston.longestElement = utils.longestElement;
winston.config = require('winston/config');
var internal = require('./winston/internal');
winston.hash = internal.hash;
winston.clone = internal.clone;
winston.longestElement = internal.longestElement;
winston.config = require('./winston/config');
winston.addColors = winston.config.addColors;
winston.Logger = require('winston/logger').Logger;

Expand All @@ -48,7 +46,7 @@ winston.Logger = require('winston/logger').Logger;
// winston.error('some error');
//
var defaultLogger = new (winston.Logger)({ transports: [new (winston.transports.Console)()] });
utils.setLevels(winston, null, defaultLogger.levels);
internal.setLevels(winston, null, defaultLogger.levels);

['log', 'add', 'remove', 'profile', 'extend', 'cli'].forEach(function (method) {
winston[method] = function () {
Expand All @@ -58,7 +56,7 @@ utils.setLevels(winston, null, defaultLogger.levels);

winston.cli = function (foo, bar) {
winston.padLevels = true;
utils.setLevels(winston, defaultLogger.levels, winston.config.cli.levels);
internal.setLevels(winston, defaultLogger.levels, winston.config.cli.levels);
defaultLogger.setLevels(winston.config.cli.levels);
winston.config.addColors(winston.config.cli.colors);

Expand All @@ -71,7 +69,7 @@ winston.cli = function (foo, bar) {
};

winston.setLevels = function (levels) {
utils.setLevels(winston, defaultLogger.levels, levels);
internal.setLevels(winston, defaultLogger.levels, levels);
defaultLogger.setLevels(levels);
};

Expand Down
2 changes: 1 addition & 1 deletion lib/winston/utils.js → lib/winston/internal.js
@@ -1,5 +1,5 @@
/*
* index.js: Top-level include for Winston
* internal.js: Internal helper and utility functions for winston
*
* (C) 2010 Charlie Robbins
* MIT LICENCE
Expand Down
4 changes: 2 additions & 2 deletions lib/winston/logger.js
Expand Up @@ -11,7 +11,7 @@ require.paths.unshift(require('path').join(__dirname, '..'));
var util = require('util'),
events = require('events'),
winston = require('winston'),
utils = require('./utils');
internal = require('./internal');

function capitalize(str) {
return str && str[0].toUpperCase() + str.slice(1);
Expand Down Expand Up @@ -225,7 +225,7 @@ Logger.prototype.profile = function (id) {
};

Logger.prototype.setLevels = function (current) {
return utils.setLevels(this, this.levels, current);
return internal.setLevels(this, this.levels, current);
};

Logger.prototype.cli = function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/winston/transports/console.js
Expand Up @@ -9,7 +9,7 @@
var events = require('events'),
util = require('util'),
colors = require('colors'),
log = require('./../utils').log;
log = require('../internal').log;

//
// ### function Console (options)
Expand Down
2 changes: 1 addition & 1 deletion lib/winston/transports/file.js
Expand Up @@ -11,7 +11,7 @@ var events = require('events'),
path = require('path'),
util = require('util'),
colors = require('colors'),
log = require('./../utils').log;
log = require('../internal').log;

//
// ### function File (options)
Expand Down
4 changes: 2 additions & 2 deletions lib/winston/transports/loggly.js
Expand Up @@ -9,7 +9,7 @@
var events = require('events'),
loggly = require('loggly'),
util = require('util'),
utils = require('./../utils');
internal = require('../internal');

//
// ### function Loggly (options)
Expand Down Expand Up @@ -76,7 +76,7 @@ util.inherits(Loggly, events.EventEmitter);
// Core logging method exposed to Winston. Metadata is optional.
//
Loggly.prototype.log = function (level, msg, meta, callback) {
var message = utils.clone(meta);
var message = internal.clone(meta);
message.level = level;
message.message = msg;

Expand Down
6 changes: 3 additions & 3 deletions lib/winston/transports/webhook.js
Expand Up @@ -9,7 +9,7 @@
var events = require('events'),
http = require('http'),
util = require('util'),
utils = require('./../utils');
internal = require('../internal');

//
// ### function WebHook (options)
Expand Down Expand Up @@ -61,7 +61,7 @@ Webhook.prototype.log = function (level, msg, meta, callback) {
}

var self = this,
message = utils.clone(meta),
message = internal.clone(meta),
options,
req;

Expand Down Expand Up @@ -101,7 +101,7 @@ Webhook.prototype.log = function (level, msg, meta, callback) {
req.write(JSON.stringify({
method: 'log',
params: {
timestamp: utils.timestamp(),
timestamp: internal.timestamp(),
msg: msg,
level: level,
meta: meta
Expand Down

0 comments on commit eb5f9e5

Please sign in to comment.