[Twisted-Python] Log output formatting (was Re: logging question)

Tim Allen screwtape at froup.com
Wed Nov 30 21:57:52 EST 2011

On Wed, Nov 30, 2011 at 01:04:27PM -0000, exarkun at twistedmatrix.com wrote:
> On 04:07 am, screwtape at froup.com wrote:
> >If the standard Twisted logging functions automatically constructed
> >LogMessage instances from dict instances, it should be easy enough for
> >future ILogObserver implementations to do the right thing (by just
> >calling str(msg)). Of course, they could also do more sophisticated
> >things like pulling particular keys out of the message to set
> >observer-specific message properties (like syslog channel and severity,
> >etc.)
> Oooorrrr there could be a function that takes a dict intended to 
> represent a text message and returns that message as a string.

As mentioned, we already have one of those in the form of
textFromEventDict(). The trouble is that everybody who writes
a LogObserver needs to know that it exists, and remember to call it. If
it were the __str__() method of a LogMessage object, they'd have to go
out of their way to *not* do the right thing.

More information about the Twisted-Python mailing list