logging and daemons

Fernando M. Maresca fmaresca at gmail.com
Mon Feb 16 14:19:35 EST 2009


On Mon, Feb 16, 2009 at 10:11:51AM -0800, Scott David Daniels wrote:
> Fernando M. Maresca wrote:
>  On Mon, Feb 16, 2009 at 05:07:45AM -0800, Garrett Cooper wrote:
>>> You can actually set sys.std[err|out] to your ?file? descriptor of
>>> choice in python ....
>> Yes, but I'm trying to use *TimedRotating*FileHandler, which makes the
>> fd of the logfile change in every rotation of the logfile. So the direct
>> approach of std[out|err] redirection to the logfile fd obtained from
>> the logger instance is unusable (it works fine with a simple file
>> handler). 
>
> Right, so you stick something in as stderr/stdout that talks to the
> logfile.  That is, something like:
>
>     import sys
>
>     class MyFakeStdout(object):
>         def flush(self):
>             pass
>         def write(self, text):
>             <code to actually do the logging>
>     sys.stderr = sys.stdout = MyFakeStdout()
>
Thanks a lot for the input.
That's pretty much what I'm doing right now, just wondered if were a
cleanest way.

Cheers,

-- 
Fernando
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 204 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090216/0900b063/attachment-0001.sig>


More information about the Python-list mailing list