[Zope] Write log file from script

Chris Withers chris at simplistix.co.uk
Mon Oct 10 05:05:05 EDT 2005


Dave Kuhlman wrote:
> 
> Why not zLOG?  Look at:
> 
>     Zope-2.8.1-home/lib/python/zLOG/__init__.py

Well, zLOG is hopefully going away some time soon ;-)

You should really be using the python logging module, for which zLOG is 
now just a facade:

import logging
logger = logging.getLogger('event.whatever')

logger.info('Argh! Help, the world with end in %i seconds',end_of_time)

I'm just writing a proposal to make this available in untrusted code 
such as Script (Python)'s, but in the meantime, you can use an external 
method:

import logging

logger = logging.getLogger('event.myapplogger')

def log(self,level,message,*args,exc_info=False):

     logger.log(getattr(logging,level),
                message,
                *args,
                exc_info = exc_info

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope mailing list