Permalink
Browse files

use "finsh" event to write msg on response time

  • Loading branch information...
1 parent d12d6e9 commit 828e090bf2d2cd8cc9e433b430e30ad7d2657194 @youngjay committed Apr 27, 2012
Showing with 5 additions and 8 deletions.
  1. +5 −8 lib/middleware/logger.js
View
@@ -143,14 +143,11 @@ exports = module.exports = function logger(options) {
stream.write(line + '\n', 'ascii');
// proxy end to output logging
} else {
- var end = res.end;
- res.end = function(chunk, encoding){
- res.end = end;
- res.end(chunk, encoding);
- var line = fmt(exports, req, res);
- if (null == line) return;
- stream.write(line + '\n', 'ascii');
- };
+ res.on('finish', function(chunk, encoding) {
+ var line = fmt(exports, req, res);
+ if (null == line) return;
+ stream.write(line + '\n', 'ascii');
+ });
}

0 comments on commit 828e090

Please sign in to comment.