nomiddlename/log4js-node — pull request #258 by osher (2014-11-04 15:29:53+00:00)
Title: 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
)

First, the fix just used `setTimeout(function() { /*emit the log entry*/ }, 5)`, 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