Extending logging module

Vinay Sajip vinay_sajip at yahoo.co.uk
Mon Aug 13 14:25:36 CEST 2007


On Aug 9, 9:08 pm, jay <titleistf... at gmail.com> wrote:
> It actually worked, but this is not the way I would like to handle the
> problem.  I would prefer to extend the classes instead.  However, I'm
> not too familiar with that, and I had to change things in so many
> places, I'm wondering if its even possible?  I don't like changing the
> standard libraries, what happens if I have to upgrade python?  My
> changes get overwritten.
>
> Can anyone offer some help or suggestions?  Thanks
>

Where's the difficulty in extending the SyslogHandler class? Simply
override the methods you need to provide the behaviour you want, then
use your handler instead of the standard SyslogHandler. I'm travelling
at the moment and cannot post a working example, but it should be easy
enough to do. It's just the same as extending any other Python class -
but remember to call the base class's __init__ from your own __init__,
if you provide one.

Best regards,

Vinay Sajip




More information about the Python-list mailing list