Commit Graph

15 Commits

Author SHA1 Message Date
osher
cd3971cc03 fix bug: headers are changed after log entry emits
In the original version, the following operation looks synchronic, however it is not:

```
res.end = end;
res.end(data,enc);

//emit the log entry 
```

In fact, it starts a series of async operations, in which the request may yet be changed after the request log has already been emitted
(in our case - a change on request headers was observed, probably by some low level hook or hacky wrap of some http.ServerResponse method that's involved on the process - but called asynchronously)
what leads to situation that the request log does not capture valid data.
(observed by us:
 - request headers
 - calculated end time, when concerning big content
)

The fix just used `setTimeout(function() { /*emit the log entry*/ }, 1)`, but I'm afraid it may not hold true for big contents.
Well. maybe the headers part will, but the response time calculation will lie.

The fix relays on: http://nodejs.org/api/http.html#http_event_finish
2014-11-04 17:28:52 +02:00
mishless
66872d136d Update connect-logger.js to work correctly with express
When used with express levels are wrong since send() does not call writeHead, but sets responseCode on response.
2014-07-30 13:06:51 +03:00
Matthias Adler
2118d8f7b3 fix 'remote-addr' property in connect-logger 2013-12-21 19:42:44 +01:00
Gareth Jones
81fa9c3568 removed unnecessary argument to createNoLogCondition 2013-06-05 08:38:39 +10:00
Gareth Jones
7ca517b5ed simplified createNoLogCondition 2013-06-05 08:37:27 +10:00
Gareth Jones
5d6f00eda4 fixed all lint errors except ones which require refactoring of code 2013-06-04 08:17:36 +10:00
Jure Mav
ac6284add1 Added automatic level detection to connect-logger, depends on http status response.
Update of connect logger example code, compatible with express 3.x
2013-05-11 16:17:23 +02:00
Gareth Jones
61078e88ef fixed the nolog tests 2012-05-09 16:40:27 +10:00
Peter 'Pita' Martischka
4cf1d1cfa4 Fixed a BUG that prevents connectlogger from working if loglevel is WARN 2011-12-07 15:28:35 +01:00
muddydixon
5aabebbdb7 change check target from req.url to req.originalUrl 2011-10-29 11:55:46 +09:00
muddydixon
b5bc9c8322 mod if nolog 2011-10-25 14:28:46 +09:00
muddydixon
c7d3ac4fe1 add nolog operation 2011-10-25 14:09:41 +09:00
Gareth Jones
0968c6709f fixed connect-logger 2011-07-19 09:08:15 +10:00
Gareth Jones
e121ca345a removed main function, now using felixge's sandboxed-module, split code into multiple files 2011-07-12 13:02:48 +10:00
Daniel Bell
59f7e0af3c Added connect/express logger. 2011-04-07 10:19:18 +10:00