From b09463d1b2742e41743c5617a39bcd3cf87fb223 Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 7 Apr 2018 21:30:01 -0400 Subject: [PATCH] async logging of info messages --- src/services/log.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/services/log.js b/src/services/log.js index 4d0abc21e..7d7c4a8fd 100644 --- a/src/services/log.js +++ b/src/services/log.js @@ -15,14 +15,22 @@ const logger = require('simple-node-logger').createRollingFileLogger({ }); function info(message) { - logger.info(message); + // info messages are logged asynchronously + setTimeout(() => { + console.log(message); - console.log(message); + logger.info(message); + }, 0); } function error(message) { + message = "ERROR: " + message; + // we're using .info() instead of .error() because simple-node-logger emits weird error for showError() - info("ERROR: " + message); + // errors are logged synchronously to make sure it doesn't get lost in case of crash + logger.info(message); + + console.trace(message); } const requestBlacklist = [ "/libraries", "/javascripts", "/images", "/stylesheets" ];