logging and daemons
yanegomi at gmail.com
Mon Feb 16 14:23:05 CET 2009
On Mon, Feb 16, 2009 at 5:15 AM, Fernando M. Maresca <fmaresca at gmail.com> wrote:
> Hello, thanks for the answer.
> 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 (it has to have read, write, and flush methods, IIRC
>> to function). The only thing is (like all things dealing with multiple
>> file descriptors like std[err|out]) the output may come in out of
>> order due to flushing and insertion into the buffers, but it shouldn't
>> be as much of an issue considering that the file descriptor for both
>> items is the same descriptor, but this is just a note of forewarning.
> 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
> I'm looking into this because I really need rotating, because when
> debugging is on, large amounts of data are logged, and because I like
> the logging module approach in every aspect.
I cannot comment about this because I haven't used this module before.
> Also, may it be possible to derive the class and add a file-like write
> method? Anyone using logging in this manner?
Indeed, yes. That's sort of what I was hinting at with my statement
that you must have a read, write and flush method for your class. Now
that I think back, other modules like pexpect implement simple logic
to deal with writing to psuedo file descriptors as well.
Locking the data streams may or may not be required -- I'm not sure
what the underlaying portions of python expose or do not expose in
terms of scheduling in output streams.
More information about the Python-list