Opened 8 years ago
Last modified 11 months ago
When logging a unicode message, the default log observer will raise an exception, causing itself to be removed from the logging system. This fact is helpfully logged so that the developer or sysadmin can rectify the problem, only there are often no log observers left to record this message... 1) We should support unicode messages 2a) There should be an ultra-safe fallback log observer which can be used to record things like the default log observer failing and being removed or 2b) The default log observer should never be permanently removed, even if it starts raising exceptions
I see a problem similar to this, but I don't use unicode, so it isn't exactly this. But I do see that *something* happens, and forever after that, my twistd.log is sadly silent.
[21:50] <foom> the proposal was to not remove the logger, until trying to log the exception first, and having that fail. [21:51] <foom> as well ensuring that unicode strings in tracebacks don't screw things up or something [21:51] <exarkun> tracebacks shouldn't be able to be unicode [21:51] <foom> then the first should fix it [21:51] <exarkun> of course that is only a moral stance, I don't know if it is true [21:52] <foom> Removing the logger because the logged item is defective is wrong, so that's the first thing that should be fixed. [21:52] <exarkun> Eh [21:52] <exarkun> That's a funny way of looking at it. [21:52] <foom> Well, if logging the exception raised when trying to log works, nothing needs to be removed. [21:53] <foom> because the system is still in a workable state. [21:53] <exarkun> right, it seems like it should work [21:53] <exarkun> it's just seems funny :) [21:53] <foom> if this proposal isn't in the bug report yet someone should add it.
Something of a fix committed at r13877. This was not the fix discussed below, because there are so many ugly cases handled in the code right now, it would have been too difficult to implement. As a long term solution, all of the stupid misfeatures of log.msg() should be deprecated and well specified features added in their place (including unicode support and interface-based observer delegation).
My bug was something different and is now filed as issue #1069.
(In [29679]) Branching to 'unicode-logging-989'
So...
I added unicode support to the three log observers we have. This basically takes the form of:
I'm not happy there's no way to specify this except by writing a tac file, but the mess of twistd command line logging options isn't something I want to touch now.
Build results, by the way.
One thing which will simplify this is to actually deprecate and disable the longer-than-one tupleness of the message passed to observers. I filed #4584 and will resolve that before trying to go further on this.
#5056 was a duplicate of this.