Using logging module to log into flash drive

Krzysztof Retel Krzysztof.Retel at googlemail.com
Tue Jun 9 14:10:08 EDT 2009


> > Anyway there's a TimedRotatingFileHandler handler in the logging package:
> > you can derive from it and change the emit/doRollover pair to hold the records
> > until a device is not ready.
>
> Hm, that might be the way to go. Will have a try.

I had another look at the logging package.
The class TimedRotatingFileHandler within the initialisation method
uses the FileHandler.__init__. Whereas the FileHandler.__init__ method
opens the stream in the 'append' mode (mode='a'). If the flash drive
is not available while you start the script, which equals that you
can't open a file in the append mode,  then the
TimedRotatingFileHandler (or FileHandler) fails.
In my opinion the only way to go through this is to use two different
handlers and once the flash drive is available then start to use the
FileHandler.

Still not sure if I want to use separate thread for checking the flash
drive availability. Probably I need to build it this way.

Regards
Krzysztof



More information about the Python-list mailing list