From 90296b92cde8622db8ac84c7f59da409068f4c18 Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Wed, 12 Jul 2017 23:29:56 -0600
Subject: [PATCH] Override winston to use console.log instead of stdout
---
app.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/app.js b/app.js
index 7a0b7bc2a5..d3b4af0697 100644
--- a/app.js
+++ b/app.js
@@ -37,6 +37,7 @@ var winston = require('winston');
var path = require('path');
var pkg = require('./package.json');
var file = require('./src/file');
+var debug = require('./src/meta/debugParams')().execArgv.length;
global.env = process.env.NODE_ENV || 'production';
@@ -52,6 +53,22 @@ winston.add(winston.transports.Console, {
stringify: (!!nconf.get('json-logging')),
});
+if (debug) {
+ var winstonCommon = require('winston/lib/winston/common');
+ // Override to use real console.log etc for VSCode debugger
+ winston.transports.Console.prototype.log = function (level, message, meta, callback) {
+ const output = winstonCommon.log(Object.assign({}, this, {
+ level,
+ message,
+ meta,
+ }));
+
+ console[level in console ? level : 'log'](output);
+
+ setImmediate(callback, null, true);
+ };
+}
+
// Alternate configuration file support
var configFile = path.join(__dirname, '/config.json');