On 11/15/2011 8:57 AM, Christopher Armstrong wrote:
If you pass a 'system' kwarg to log.msg then it will go in that field.

log.msg("hi", system="stuff") results in <date> [stuff] hi

This triggered me to look further into what LogPublisher.msg does, since I've long wanted to customize the format of the output.  I found what I wanted in http://twistedmatrix.com/documents/current/api/twisted.python.log.ILogObserver.html :

In msg(), the message gets added to the kwargs dictionary (along with a timestamp called 'time'), and that dict is passed to LogObserver.emit, which uses textFromEventDict() to create what's actually output.  This dictionary has the following keys recognized by textFromEventDict:
So, for example, you could do log.msg(format='....', foo='stuff', bar='things')

I suggest that this be added to the documentation string of the msg() method and http://twistedmatrix.com/documents/current/core/howto/logging.html.


--
Don Dwiggins
Advanced Publishing Technology