0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

better error logging

This commit is contained in:
Alex Kocharin 2013-10-22 13:37:28 +04:00
parent 782abbb86d
commit 3a407396b8

View file

@ -126,11 +126,7 @@ module.exports.log_and_etagify = function(req, res, next) {
_write.apply(res, arguments) _write.apply(res, arguments)
} }
var _end = res.end; function log() {
res.end = function(buf) {
if (buf) bytesout += buf.length
_end.apply(res, arguments)
var msg = '@{status}, user: @{user}, req: \'@{request.method} @{request.url}\''; var msg = '@{status}, user: @{user}, req: \'@{request.method} @{request.url}\'';
if (res._sinopia_error) { if (res._sinopia_error) {
msg += ', error: @{!error}'; msg += ', error: @{!error}';
@ -148,7 +144,18 @@ module.exports.log_and_etagify = function(req, res, next) {
out: bytesout, out: bytesout,
} }
}, msg); }, msg);
}; }
next();
req.on('close', function() {
log(true)
})
var _end = res.end;
res.end = function(buf) {
if (buf) bytesout += buf.length
_end.apply(res, arguments)
log()
}
next()
} }