From 0607d67c15eab58ce83cce14ada70a1e2a9f17e9 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Mon, 6 May 2013 10:43:27 -0700 Subject: [PATCH] fix(logger): configure the logger as soon as possible This is a tricky problem - we need to show some logs even before parsing the configuration. At that point, we don't know what the logger configuration is. This sets the reasonable defaults at the very beginning (rather than log4js verbose defaults) and then, sets the user specific settings as soon as possible. --- lib/config.js | 6 +++++- lib/server.js | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/config.js b/lib/config.js index ff2eba886..cb66ed39b 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,6 +1,7 @@ var path = require('path'); -var log = require('./logger').create('config'); +var logger = require('./logger'); +var log = logger.create('config'); var helper = require('./helper'); var constant = require('./constants'); @@ -239,6 +240,9 @@ var parseConfig = function(configFilePath, cliOptions) { // merge the config from config file and cliOptions (precendense) dsl.configure(cliOptions); + // configure the logger as soon as we can + logger.setup(config.logLevel, config.colors, config.loggers); + return normalizeConfig(config, configFilePath); }; diff --git a/lib/server.js b/lib/server.js index fcf3e9a56..d43a9c696 100644 --- a/lib/server.js +++ b/lib/server.js @@ -24,8 +24,6 @@ var log = logger.create(); var start = function(injector, config, launcher, globalEmitter, preprocess, fileList, webServer, resultReporter, capturedBrowsers, done) { - logger.setup(config.logLevel, config.colors, config.loggers); - config.frameworks.forEach(function(framework) { injector.get('framework:' + framework); }); @@ -231,6 +229,9 @@ start.$inject = ['injector', 'config', 'launcher', 'emitter', 'preprocess', 'fil exports.start = function(cliOptions, done) { + // apply the default logger config as soon as we can + logger.setup(constant.LOG_INFO, true, [constant.CONSOLE_APPENDER]); + var config = cfg.parseConfig(cliOptions.configFile, cliOptions); var modules = [{ helper: ['value', helper],