Explicitly flush when writing access log entries#520
Conversation
daphne 1.0.0 arranged to flush access logs immediately (django#53, django#54), but only when logging to a file. It's often convenient to log to stdout instead and rely on the systemd journal, but at the moment that results in access logs being unhelpfully block-buffered. Explicitly flush entries so that this works regardless of the logging destination.
carltongibson
left a comment
There was a problem hiding this comment.
Hi @cjwatson Thanks for this.
I'm a little reluctant to just change such a long-standing behaviour. 🤔
Q: why not just run with PYTHONUNBUFFERED in this case?
|
That's a workaround I may indeed end up using (though it's not especially urgent for us), but it seems like a less economical change. |
|
Using existing features, and keeping the behaviour of stdout in line with Python defaults seems the more economical solution to me 🤔 |
|
Depends on your point of view, I guess. Another approach to this would be #473, since Python's |
|
The main reason I don't love |
|
Yes #473 would be the way to go. If you'd like to offer a review there, we can try and get that in. |
|
I'll close in favour of #473. |
daphne 1.0.0 arranged to flush access logs immediately (#53, #54), but only when logging to a file. It's often convenient to log to stdout instead and rely on the systemd journal, but at the moment that results in access logs being unhelpfully block-buffered. Explicitly flush entries so that this works regardless of the logging destination.