Skip to content

Conversation

@cjwatson
Copy link

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.

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.
Copy link
Member

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@cjwatson
Copy link
Author

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.

@carltongibson
Copy link
Member

Using existing features, and keeping the behaviour of stdout in line with Python defaults seems the more economical solution to me 🤔

@cjwatson
Copy link
Author

Depends on your point of view, I guess. Another approach to this would be #473, since Python's logging module normally flushes the output stream if it can.

@cjwatson
Copy link
Author

The main reason I don't love PYTHONUNBUFFERED is that unbuffered is not the same as line-buffered, and I worry that it might cause lines of output (or indeed error output, since PYTHONUNBUFFERED affects stderr too) to end up being interleaved in some cases where any kind of multi-threading is involved.

@carltongibson
Copy link
Member

Yes #473 would be the way to go.

If you'd like to offer a review there, we can try and get that in.

@carltongibson
Copy link
Member

I'll close in favour of #473.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants