Andrius Laukavičius <anlauka...@gmail.com> added the comment:

Peter,
well I don't have deep experience with logging lib to know all ins and outs. So 
I might not be correct person to define what should be changed specifically. 
But I think it should be consistent on all standard libraries how it handles 
stdout/stderr, unless there is a reason to do it differently?

For example `print` to me seems to behave how I expect, because if stdout is 
redirected elsewhere, print uses redirected stdout without a problem. 

Now with logging, it does feel strange that on first call of `logging`, it sets 
internally stderr where it is pointing at that moment and forgets about it. You 
call logging again, and it naively expects stderr to be where it was on initial 
call, when in reality it might be redirected elsewhere (as in my case).

Maybe you know the reasoning why logging even needs to behave this way? Though 
if logging behaves this way, why print behaves differently?

So to summarize this, I think all libraries should respect stdout/stderr where 
it is and have some unified way/interface (like I expected 
redirect_stdout/redirect_stderr to be) to specify that stdout/stderr has 
changed and related libraries must update their state regarding that (logging 
library case) or simply rely on where stdout/stderr is pointed, so nothing 
needs to be done on that library once stdout/stderr is redirected.


To comment on your view about `dump_stuff(dest)`. Well I think this suits well, 
when you have something to dump already, but what if something to dump is what 
is produced via stdout/stderr and you need to capture it first? How can I do 
that without first redirecting stdout where I need to?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36193>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to