Closed ztane closed 4 years ago
I’m not super comfortable overriding Python defaults here. It feels like it’ll just hide a deeper config issue in other print statements.
@mmerickel I am proposing changing only the few prints in pserve.py
, as it is the only place which actually produces logging, and which is hard to monkeypatch. There is only one other place in the Pyramid codebase which semantically should use sys.stderr
which would be the usage description in alchemy
scaffold, which should go to sys.stderr
but then those pedantic can change it themselves.
But the pserve.py
prints cannot be changed. The problem is that the stdout of C stdio is supposed to be line or full buffered depending on where it is connected, whereas stderr is unbuffered. The problem with these statements now is that in many cases they show up in logs only when the program is terminated. translogger et all do log into stderr, because those messages show up in my terminal before the messages from pserve
(which show only when I terminate the container).
pserve.py
has this method for outputting verbose diagnostics:and a couple direct
print
s.I was running my code in Docker and thought there was something really wrong with my container as I didn't get the pserve diagnostics messages. Turns out that it was just because
stdout
was in fully-buffered mode.Suggestion: change
print
s toprint(..., file=sys.stderr)
... then one can see the message in logs before a full block is output to stdout ;)