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
signature.asc
Description: Digital signature
-- http://mail.python.org/mailman/listinfo/python-list