python safe scripting

i3dmaster i3dmaster at gmail.com
Wed Nov 21 22:07:36 CET 2007


On Nov 21, 12:44 pm, "Guilherme Polo" <ggp... at gmail.com> wrote:
> 2007/11/21, Vladimir Rusinov <vladi... at greenmice.info>:
>
> > Hello!
>
> > In one my project (it's logfile manager) I want to implement 'smart'
> > configuration files, e.g.
>
> > logfile("/var/log/messages")
> > if (size() > 10*1024*1024) and (lavg() < 5):
> >     execute("my_log_alerter")
> >    rotate(save=10, compress='bzip2')
>
> > how can I safely do this?
>
> > --
> > Vladimir Rusinov
> > GreenMice Solutions: IT-ÒÅÛÅÎÉÑ ÎÁ ÂÁÚÅ Linux
> >  http://greenmice.info/
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> logging already provides the rotating
>
> from logging.handlers import RotatingFileHandler
> help(RotatingFileHandler)
>
> --
> -- Guilherme H. Polo Goncalves

But the original RotatingFileHanlder does not offer compressing
facility where the sample code that the author provides seems to
indicate that he wants some sort of handling on that... Extends the
class and override the doRollover method would probably do what you
need.



More information about the Python-list mailing list