Merge pull request #1 from idalv/automation
Update connect-logger.js to work correctly with express
This commit is contained in:
commit
6314e4a344
@ -84,6 +84,14 @@ function getLogger(logger4js, options) {
|
||||
res.end = end;
|
||||
res.end(chunk, encoding);
|
||||
res.responseTime = new Date() - start;
|
||||
//status code response level handling
|
||||
if(res.statusCode && options.level === 'auto'){
|
||||
level = levels.INFO;
|
||||
if(res.statusCode >= 300) level = levels.WARN;
|
||||
if(res.statusCode >= 400) level = levels.ERROR;
|
||||
} else {
|
||||
level = levels.toLevel(options.level, levels.INFO);
|
||||
}
|
||||
if (thislogger.isLevelEnabled(level)) {
|
||||
if (typeof fmt === 'function') {
|
||||
var line = fmt(req, res, function(str){ return format(str, req, res); });
|
||||
|
Loading…
Reference in New Issue
Block a user