[Twisted-Python] Custom logging for twistd plugin

Garret Heaton powdahound at gmail.com
Fri Jun 12 16:33:26 EDT 2009

I'm looking to make some changes to the way a twistd
information. The docs on
the application
currently mention how plugins fit in.

My main goal is to have the log include information about the log level of
each message represented as either text or an integer (like logging.DEBUG,
etc). This would make log monitoring tools and alerts much more accurate as
well as easier to write. I'd also like to be able to call log methods for
each level (log.debug(), log.error(), etc) instead of only having log.msg().

For example, I'd prefer to turn:
2009-06-12 13:04:12-0700 [-] Foo service starting
2009-06-12 13:04:12-0700 [-] Loaded config from /etc/foo/missing.cfg
2009-06-12 13:04:12-0700 [-] Log file does not exist: /etc/foo/missing.cfg
into something like:
20|2009-06-12 13:04:12|Foo service starting
10|2009-06-12 13:04:12|Loaded config from /etc/foo/missing.cfg
50|2009-06-12 13:04:12|Log file does not exist: /etc/foo/missing.cfg

(10 = logging.DEBUG, 20 = logging.INFO, 50 = logging.CRITICAL from Python's
logging module <http://docs.python.org/library/logging.html>)

I've looked through most of the current logging code but I'm new to both
Python and Twisted and am not sure if adding what I want through subclassing
is the best approach or even a possibility.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20090612/86b751e8/attachment.htm 

More information about the Twisted-Python mailing list