[Tutor] python logging module: two handlers writing to the same file - okay?

Kent Johnson kent37 at tds.net
Mon Dec 17 02:56:19 CET 2007


Ricardo Aráoz wrote:
> Why should it be all or nothing. Couldn't the programmer indicate that
> both handlers use the same file?

It would be very easy to do this using StreamHandlers instead of 
FileHandlers. It would also be easy to make a FileHandler subclass that 
keeps a map from file name to file objects so if the same file is given 
to two instances it reuses the first one. This could be specified as the 
handler in the config file even.

Python has 'batteries included' but sometimes you have to add some 
wiring ;-)

Kent


More information about the Tutor mailing list