[Twisted-Python] Twisted, twistd and logging
Phil Christensen
phil at bubblehouse.org
Thu Jun 19 08:48:30 MDT 2008
On Jun 19, 2008, at 2:21 AM, Tim Allen wrote:
> My second thought was to use twisted.python.log, but that brings its
> own set of problems:
>
> 1. twisted.python.syslog isn't very... complete. For starters, it
> doesn't let you specify the syslog facility, and even if it did,
> twistd would need to be extended to support it.
It's true that the syslog support is very experimental at this point,
but what would need to be changed about twistd to support the
necessary development?
I think the most likely scenario is that the standard logging code
assumes logging will return immediately, but I feel like this could be
worked around by having some kind of log queue that gets sent to
syslog by some background thread (or better yet, a callLater pattern).
> 2. As has been discussed in the list archives, t.p.log doesn't support
> log-levels. While I can see glyph's point about the arbitraryness
> of fixed log-levels, I really do want to distinguish between
> "forensic record of ordinary operation" and "Danger, Will
> Robinson!"
t.p.log doesn't implicitly support log levels, but you can add
arbitrary keywords to your call to log.msg. Then your observer can
take care of routing log messages to the right places.
> I think the best way of solving my problems would be to:
>
> a) update t.p.syslog so that it supports a 'facility' parameter.
> b) update t.p.syslog so that log-messages with 'isError' true are
> logged with the LOG_ALERT priority rather than the default.
> c) update the Unix version of twistd to support a 'syslogFacility'
> command-line parameter.
>
> Would such a patch be accepted? If necessary, I could replace (b) with
> a syslog-based LogObserver in my own code, but I'm keen to have (a)
> and
> (c) in the Twisted code-base.
I can't speak to whether such a patch would be accepted, but I know I
have a couple of projects I've wanted to use syslogging for, and it
would be great to have a stable solution in Twisted. However, the core
dev team is fairly well inundated, so while you're working on a patch/
review, you might consider investigating another option in parallel.
If you package your code separately and join the Twisted Community
Code project on Launchpad, you can get your code out there and in
front of eyeballs while you work on getting a patch accepted into
Twisted. If you can draw a reasonable amount of user attention, this
may help with both testing and review, and make it easier to get your
patch into Twisted proper.
-phil
More information about the Twisted-Python
mailing list