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,