[Twisted-Python] Re: [Twisted-commits] r14614 - Describe log.debug, and 'printed' and 'debug' log dict items.

James Y Knight foom at fuhm.net
Tue Oct 4 21:18:40 MDT 2005


On Oct 4, 2005, at 5:01 PM, glyph at divmod.com wrote:
> On Tue, 4 Oct 2005 16:31:58 -0400, James Y Knight <foom at fuhm.net>  
> wrote:
>> log.msg("error message", isError=1)
>
> Please don't ever do this.  Log observers which check the isError  
> flag expect a stricter interface; a Failure object, for one thing,  
> like log.err puts there.

Actually they don't. They expect that the failure keyword may or may  
not be present. The only use of "levels" we have (DefaultObserver  
only showing error messages) filters out any non-isError messages, so  
there are circumstances in which you want to make sure you're  
emitting an isError=1 message.

> Really this should be using the interface keyword arg that itamar  
> mentioned, set to something like log.IErrorReport.  To ensure  
> portability when that does become the convention, use log.err.

But sometimes you cannot use log.err because you want to emit an  
error-level _message_, rather than the repr of an object, an  
exception, or a failure.

Notice how log.err("Foo!") doesn't actually do what you might hope.  
Contrast with log.msg("Foo!", isError=1) which does.

James





More information about the Twisted-Python mailing list