[Python-ideas] Logging: a more perseverent version of the StreamHandler?

Steven D'Aprano steve at pearwood.info
Sun Jan 28 19:41:48 EST 2018


On Fri, Jan 26, 2018 at 09:46:51PM +0100, liam marsh wrote:
> Hello,
> Some time ago, I set up some logging using stdout in a program with the 
> `stdout_redirected()` context manager, which had to close and reopen 
> stdout to work.
> Unsurprisingly, the StreamHandler didn't take it well.
> 
> So I made a Handler class which is able to reload the stream

[...]

> What do you think? (about the idea, the implementation, and the way I 
> wrote this email)|

I'll admit that I'm not actually very interested in the problem you're 
solving, I've never hit that problem so I'll leave it for those who have 
to comment on the idea and implementation.

But I'll comment on the email: for some reason, the implementation you 
give has extraneous pipes | at the start and end of each line, e.g.:


|class ReloadingHandler(StreamHandler):|
|    """|
|    A stream handler which reloads the stream object from one place if an error occurs|
|    """|

Between the extraneous pipes and the lines being line-wrapped, the code 
has ended up severely mangled.

(Code being emailed probably needs to stay below 78 characters per line 
to avoid being wrapped at the ends of lines.)



-- 
Steve


More information about the Python-ideas mailing list