From ac4b74588ed6bd643a9c65a6116e3b0ed6c21835 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 27 Jul 2018 17:20:36 -0400 Subject: [PATCH] move intercept logs to utils --- lib/utils/utils.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 436d4831..4a6bb64b 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -494,6 +494,31 @@ function timer(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } +function interceptLogs(consoleContext, logger) { + let context = {}; + context.console = consoleContext; + + context.console.log = function() { + logger.info(normalizeInput(arguments)); + }; + context.console.warn = function() { + logger.warn(normalizeInput(arguments)); + }; + context.console.info = function() { + logger.info(normalizeInput(arguments)); + }; + context.console.debug = function() { + // TODO: ue JSON.stringify + logger.debug(normalizeInput(arguments)); + }; + context.console.trace = function() { + logger.trace(normalizeInput(arguments)); + }; + context.console.dir = function() { + logger.dir(normalizeInput(arguments)); + }; +} + module.exports = { joinPath, dirname,