aboutsummaryrefslogtreecommitdiffstats
path: root/karma-shared.conf.js
diff options
context:
space:
mode:
authorVojta Jina2013-12-02 13:51:09 -0800
committerVojta Jina2013-12-02 22:51:15 -0800
commit09271a8ab945df19ec3aacf43f60c458fafd82fd (patch)
tree1e4f04d580b64a414ac794bea0b672c0d5c07ba0 /karma-shared.conf.js
parent5a8d9acacbb8a2b9175da196cbaf8ff93bac28c8 (diff)
downloadangular.js-09271a8ab945df19ec3aacf43f60c458fafd82fd.tar.bz2
chore(travis): ignore 404 warnings, debug log into file
This is a terrible hack/workaround, however I don't think there is any better way to achieve this with log4js.
Diffstat (limited to 'karma-shared.conf.js')
-rw-r--r--karma-shared.conf.js42
1 files changed, 40 insertions, 2 deletions
diff --git a/karma-shared.conf.js b/karma-shared.conf.js
index 3659e582..ac8e4f91 100644
--- a/karma-shared.conf.js
+++ b/karma-shared.conf.js
@@ -111,14 +111,52 @@ module.exports = function(config, specificOptions) {
if (process.env.TRAVIS) {
+ config.logLevel = config.LOG_DEBUG;
config.transports = ['websocket', 'xhr-polling'];
config.browserStack.build = 'TRAVIS ' + process.env.TRAVIS_BUILD_ID;
// Debug logging into a file, that we print out at the end of the build.
config.loggers.push({
type: 'file',
- filename: process.env.LOGS_DIR + '/' + (specificOptions.logFile || 'karma.log'),
- level: config.LOG_DEBUG
+ filename: process.env.LOGS_DIR + '/' + (specificOptions.logFile || 'karma.log')
});
}
+
+
+ // Terrible hack to workaround inflexibility of log4js:
+ // - ignore web-server's 404 warnings,
+ // - ignore DEBUG logs (on Travis), we log them into a file instead.
+ var IGNORED_404 = [
+ '/favicon.ico',
+ '/%7B%7BtestUrl%7D%7D',
+ '/someSanitizedUrl',
+ '/{{testUrl}}'
+ ];
+ var log4js = require('./node_modules/karma/node_modules/log4js');
+ var layouts = require('./node_modules/karma/node_modules/log4js/lib/layouts');
+ var originalConfigure = log4js.configure;
+ log4js.configure = function(log4jsConfig) {
+ var consoleAppender = log4jsConfig.appenders.shift();
+ var originalResult = originalConfigure.call(log4js, log4jsConfig);
+ var layout = layouts.layout(consoleAppender.layout.type, consoleAppender.layout);
+
+
+
+ log4js.addAppender(function(log) {
+ // ignore web-server's 404s
+ if (log.categoryName === 'web-server' && log.level.levelStr === config.LOG_WARN &&
+ IGNORED_404.indexOf(log.data[0]) !== -1) {
+ return;
+ }
+
+ // on Travis, ignore DEBUG statements
+ if (process.env.TRAVIS && log.level.levelStr === config.LOG_DEBUG) {
+ return;
+ }
+
+ console.log(layout(log));
+ });
+
+ return originalResult;
+ };
};