On 09:10 pm, kevin.h...@gmail.com wrote: >On Wed, Nov 16, 2011 at 2:27 PM, Don Dwiggins ><ddwigg...@advpubtech.com>wrote: >>** >>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: >> >> - message: A tuple of str containing messages to be logged. >> - system: A str which indicates the "system" which is generating >>this >> event. >> - isError: A bool indicating whether this event represents an >>error. >> - failure: A >>failure.Failure<http://twistedmatrix.com/documents/current/api/twisted.python.failure.Failure.html>instance, >> >>required >> if the event is an error. >> - why: Used as header of the traceback in case of errors. >> - format: A string format used in place of message to customize the >> event. The intent is for the observer to format a message by doing >> something like format % eventDict. >> >>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.
`msg` doesn't really care about what you give it. It doesn't support the `format` keyword in any particular way. It's the job of a log observer to handle that sort of thing. So it could certainly be documented, but don't mix things together that are unrelated. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python