Message337193
I see various options to address this.
(1) Change basicConfig() to use __stderr__ instead of stderr to avoid redirections from within the script.
(2) Change your script to call basicConfig() explicitly, before the temporary redirection takes place.
In both cases logging output will always go to the "real" stderr.
(3) Write a special handler that fetches sys.stderr lazily. Here's a sketch:
class StderrHandler(logging.StreamHandler):
def __init__(self):
super().__init__()
def get_stream(self):
return sys.stderr
def set_stream(self, _value):
pass
stream = property(get_stream, set_stream)
logging.basicConfig(handlers=[StderrHandler()])
As written this is likely to fail with multiple threads...
My personal favourite is option (2). |
|
Date |
User |
Action |
Args |
2019-03-05 14:37:58 | peter.otten | set | recipients:
+ peter.otten, vinay.sajip, xtreak, andriusl |
2019-03-05 14:37:58 | peter.otten | set | messageid: <1551796678.83.0.224252752433.issue36193@roundup.psfhosted.org> |
2019-03-05 14:37:58 | peter.otten | link | issue36193 messages |
2019-03-05 14:37:58 | peter.otten | create | |
|