@@ -111,14 +111,52 @@ module.exports = function(config, specificOptions) {
111
111
112
112
113
113
if ( process . env . TRAVIS ) {
114
+ config . logLevel = config . LOG_DEBUG ;
114
115
config . transports = [ 'websocket' , 'xhr-polling' ] ;
115
116
config . browserStack . build = 'TRAVIS ' + process . env . TRAVIS_BUILD_ID ;
116
117
117
118
// Debug logging into a file, that we print out at the end of the build.
118
119
config . loggers . push ( {
119
120
type : 'file' ,
120
- filename : process . env . LOGS_DIR + '/' + ( specificOptions . logFile || 'karma.log' ) ,
121
- level : config . LOG_DEBUG
121
+ filename : process . env . LOGS_DIR + '/' + ( specificOptions . logFile || 'karma.log' )
122
122
} ) ;
123
123
}
124
+
125
+
126
+ // Terrible hack to workaround inflexibility of log4js:
127
+ // - ignore web-server's 404 warnings,
128
+ // - ignore DEBUG logs (on Travis), we log them into a file instead.
129
+ var IGNORED_404 = [
130
+ '/favicon.ico' ,
131
+ '/%7B%7BtestUrl%7D%7D' ,
132
+ '/someSanitizedUrl' ,
133
+ '/{{testUrl}}'
134
+ ] ;
135
+ var log4js = require ( './node_modules/karma/node_modules/log4js' ) ;
136
+ var layouts = require ( './node_modules/karma/node_modules/log4js/lib/layouts' ) ;
137
+ var originalConfigure = log4js . configure ;
138
+ log4js . configure = function ( log4jsConfig ) {
139
+ var consoleAppender = log4jsConfig . appenders . shift ( ) ;
140
+ var originalResult = originalConfigure . call ( log4js , log4jsConfig ) ;
141
+ var layout = layouts . layout ( consoleAppender . layout . type , consoleAppender . layout ) ;
142
+
143
+
144
+
145
+ log4js . addAppender ( function ( log ) {
146
+ // ignore web-server's 404s
147
+ if ( log . categoryName === 'web-server' && log . level . levelStr === config . LOG_WARN &&
148
+ IGNORED_404 . indexOf ( log . data [ 0 ] ) !== - 1 ) {
149
+ return ;
150
+ }
151
+
152
+ // on Travis, ignore DEBUG statements
153
+ if ( process . env . TRAVIS && log . level . levelStr === config . LOG_DEBUG ) {
154
+ return ;
155
+ }
156
+
157
+ console . log ( layout ( log ) ) ;
158
+ } ) ;
159
+
160
+ return originalResult ;
161
+ } ;
124
162
} ;
0 commit comments