From 37d3995ac15c32d49061705180eabf83f5ade150 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 28 Apr 2020 17:05:15 -0400 Subject: [PATCH] unify format of console output with stored logs --- lib/log.js | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/lib/log.js b/lib/log.js index 35dfad7a3..386ee6b41 100644 --- a/lib/log.js +++ b/lib/log.js @@ -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); };