Skip to content

Commit

Permalink
fix(logger): configure the logger as soon as possible
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vojtajina committed May 6, 2013
1 parent 7233c5f commit 0607d67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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);
};

Expand Down
5 changes: 3 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 0607d67

Please sign in to comment.