Using logging module to log into flash drive

Krzysztof Retel Krzysztof.Retel at
Wed Jun 10 09:19:49 CEST 2009

On Jun 9, 7:57 pm, Carl Banks <pavlovevide... at> wrote:
> On Jun 9, 8:57 am, kretel <Krzysztof.Re... at> wrote:
> > Hi All,
> > I am trying to implement the following functionality:
> > 1. log messages to the flash drive
> > 2. if the flash drive is not available, switch handler to the
> > BufferringHandler and log into buffer,
> > 3. once the flash drive is plugged in and available store the logs
> > from BufferHandler into that flash drive and switch the handler into
> > RotateFileHandler.
> > Which approach would you suggest to use while implementing this
> > functionality? One that come into my mind is to have one process or
> > thread to check periodically if the flashdrive is available, and have
> > a flag that will indicate that we can store the logs into the flash
> > drive. But I don't particularly like this approach.
> > Would you do it different way?
> > Any suggestions are appreciated.
> I'd refactor the steps this way:
> 1. log messages to a buffer
> 2. periodically flush the buffer to the flash drive, if it's available
> The "periodically" part could be accomplished with a thread or
> scheduled delays, however suits your application.  It might not be a
> final if you need to log messages promptly, but that's how I'd begin.
> Carl Banks

Hi Carl,

Thanks for the advice. I haven't think about it this way, but it looks
like that might be the starting point.


More information about the Python-list mailing list