From 0d5021eebc0e6a31c0867a905fe5149b1258522c Mon Sep 17 00:00:00 2001 From: Misha Wolfson Date: Wed, 14 Dec 2016 17:04:30 -0500 Subject: [PATCH 1/2] Add stderr to logger config --- lib/logger.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/logger.js b/lib/logger.js index 8f53dc1..783cff8 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -16,6 +16,8 @@ if (config.get('bunyan') || config.get(env + ':use_bunyan')) { for (var i = 0; i < settings.streams.length; i++) { if (settings.streams[i].stream === 'process.stdout') { settings.streams[i].stream = process.stdout; + } else if (settings.streams[i].stream === 'process.stderr') { + settings.streams[i].stream = process.stderr; } } From a989f4d60c7ff00eb45e63051c0bd0d8da43467f Mon Sep 17 00:00:00 2001 From: Misha Wolfson Date: Wed, 14 Dec 2016 18:23:30 -0500 Subject: [PATCH 2/2] Parse global stream config option --- lib/logger.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 783cff8..57675bb 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -13,13 +13,16 @@ var output; if (config.get('bunyan') || config.get(env + ':use_bunyan')) { var settings = _.cloneDeep(config.get(env + ':bunyan')); - for (var i = 0; i < settings.streams.length; i++) { - if (settings.streams[i].stream === 'process.stdout') { - settings.streams[i].stream = process.stdout; - } else if (settings.streams[i].stream === 'process.stderr') { - settings.streams[i].stream = process.stderr; - } - } + // Stream can be specified either in settings.streams[ix] or globally in settings.stream + _([settings.streams, settings]) + .flatten() + .forEach(function (settingObj) { + if (settingObj.stream === 'process.stdout') { + settingObj.stream = process.stdout; + } else if (settingObj.stream === 'process.stderr') { + settingObj.stream = process.stderr; + } + }); output = bunyan.createLogger(settings); } else {