|
|
|
@ -23,29 +23,13 @@ var write = function (ctx, content) {
|
|
|
|
|
// various degrees of logging
|
|
|
|
|
const logLevels = Logger.levels = ['silly', 'verbose', 'debug', 'feedback', 'info', 'warn', 'error'];
|
|
|
|
|
|
|
|
|
|
var handlers = {
|
|
|
|
|
silly: function (ctx, time, tag, info) {
|
|
|
|
|
console.log('[SILLY]', time, tag, info);
|
|
|
|
|
},
|
|
|
|
|
debug: function (ctx, time, tag, info) {
|
|
|
|
|
console.log('[DEBUG]', time, tag, info);
|
|
|
|
|
},
|
|
|
|
|
verbose: function (ctx, time, tag, info) {
|
|
|
|
|
console.log('[VERBOSE]', time, tag, info);
|
|
|
|
|
},
|
|
|
|
|
feedback: function (ctx, time, tag, info) {
|
|
|
|
|
console.log('[FEEDBACK]', time, tag, info);
|
|
|
|
|
},
|
|
|
|
|
info: function (ctx, time, tag, info) {
|
|
|
|
|
console.info('[INFO]', time, tag, info);
|
|
|
|
|
},
|
|
|
|
|
warn: function (ctx, time, tag, info) {
|
|
|
|
|
console.warn('[WARN]', time, tag, info);
|
|
|
|
|
},
|
|
|
|
|
error: function (ctx, time, tag, info) {
|
|
|
|
|
console.error('[ERROR]', time, tag, info);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var handlers = {};
|
|
|
|
|
['silly', 'debug', 'verbose', 'feedback', 'info'].forEach(function (level) {
|
|
|
|
|
handlers[level] = function (ctx, content) { console.log(content); };
|
|
|
|
|
});
|
|
|
|
|
['warn', 'error'].forEach(function (level) {
|
|
|
|
|
handlers[level] = function (ctx, content) { console.error(content); }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var noop = function () {};
|
|
|
|
|
|
|
|
|
@ -65,7 +49,7 @@ var createLogType = function (ctx, type) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ctx.logToStdout && typeof(handlers[type]) === 'function') {
|
|
|
|
|
handlers[type](ctx, time, tag, info);
|
|
|
|
|
handlers[type](ctx, content);
|
|
|
|
|
}
|
|
|
|
|
write(ctx, content);
|
|
|
|
|
};
|
|
|
|
|