Not sure why these were classes to begin with
This commit is contained in:
parent
7379ce5eea
commit
f5de644af7
|
@ -27,10 +27,10 @@ var Logger = module.exports = {};
|
|||
//
|
||||
// Returns the new logger instance
|
||||
Logger.setup = function setup(logger) {
|
||||
if (logger == null) { logger = new BasicLogger(); }
|
||||
if (logger == null) { logger = BasicLogger; }
|
||||
|
||||
if (logger === false) {
|
||||
this.logger = new NullLogger();
|
||||
this.logger = NullLogger;
|
||||
} else {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
// The BasicLogger pushes stuff to console.log. Nothing more, nothing less.
|
||||
var BasicLogger = module.exports = function BasicLogger() {};
|
||||
|
||||
BasicLogger.prototype.toString = function() {
|
||||
return "BasicLogger";
|
||||
};
|
||||
|
||||
var getArgs = function(args) {
|
||||
return args.length >= 1 ? [].slice.call(args, 0) : [];
|
||||
};
|
||||
|
||||
var logString = function(type) {
|
||||
var upcase = String(type).toUpperCase(),
|
||||
time = new Date().toISOString();
|
||||
var time = new Date().toISOString(),
|
||||
type = String(type).toUpperCase(),
|
||||
padded = String(" " + type).slice(-5);
|
||||
|
||||
var padded = String(" " + upcase).slice(-5);
|
||||
|
||||
return upcase[0] + ", [" + time + "] " + padded + " -- :";
|
||||
return type[0] + ", [" + time + "] " + padded + " -- :";
|
||||
};
|
||||
|
||||
// The BasicLogger logs to console.log
|
||||
var BasicLogger = module.exports = {
|
||||
toString: function() { return "BasicLogger"; },
|
||||
};
|
||||
|
||||
['debug', 'info', 'warn', 'error', 'fatal'].forEach(function(type) {
|
||||
BasicLogger.prototype[type] = function() {
|
||||
BasicLogger[type] = function() {
|
||||
var args = getArgs(arguments);
|
||||
return console.log.apply(console, [].concat(logString(type), args));
|
||||
};
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
// The NullLogger is designed for cases where you want absolutely nothing to
|
||||
// print to anywhere. Every proxied method from the Logger returns a noop.
|
||||
var NullLogger = module.exports = function NullLogger() {};
|
||||
|
||||
NullLogger.prototype.toString = function() {
|
||||
return "NullLogger";
|
||||
var NullLogger = module.exports = {
|
||||
toString: function() { return "NullLogger"; }
|
||||
};
|
||||
|
||||
NullLogger.prototype.debug = function() {};
|
||||
NullLogger.prototype.info = function() {};
|
||||
NullLogger.prototype.warn = function() {};
|
||||
NullLogger.prototype.error = function() {};
|
||||
NullLogger.prototype.fatal = function() {};
|
||||
['debug', 'info', 'warn', 'error', 'fatal'].forEach(function(type) {
|
||||
NullLogger[type] = function() {};
|
||||
});
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
var BasicLogger = source('logger/basic_logger');
|
||||
var logger = source('logger/basic_logger');
|
||||
|
||||
var date = new Date(0).toISOString();
|
||||
|
||||
describe('BasicLogger', function() {
|
||||
var logger = new BasicLogger(),
|
||||
clock;
|
||||
var clock;
|
||||
|
||||
beforeEach(function() {
|
||||
stub(console, 'log');
|
||||
|
|
Loading…
Reference in New Issue