[Zapp-cvs-commit] ZApp ZApp_LOG.py,1.6,1.7
Brought to you by:
sspickle
|
From: <ssp...@us...> - 2004-02-17 15:48:26
|
Update of /cvsroot/zapp/ZApp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14093 Modified Files: ZApp_LOG.py Log Message: added some logging options Index: ZApp_LOG.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_LOG.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ZApp_LOG.py 5 Feb 2004 17:27:32 -0000 1.6 --- ZApp_LOG.py 17 Feb 2004 15:39:28 -0000 1.7 *************** *** 7,10 **** --- 7,30 ---- ZAPP_DEBUG_BREAK=os.environ.get('ZAPP_DEBUG_BREAK',0) + LOGINFOKEY='logInfo' + + def buildRequestLogger( REQUEST ): + + """ + Construct a dictioanry that can be used by the log method + to store logging information in the REQUEST. + """ + + logInfo = REQUEST.get(LOGINFOKEY,[]) + + if not logInfo: + REQUEST.set(LOGINFOKEY, logInfo) + + logger = { + LOGINFOKEY:logInfo, + } + + return logger + register_subsystem('ZApp') *************** *** 15,19 **** def ZApp_LOG(message, priority = INFO): ! if priority>INFO: if ZAPP_PRINT_LOG: print message --- 35,61 ---- def ZApp_LOG(message, priority = INFO): ! """ ! ZApp_LOG can use the existing Zope logging machinery, or ! do it's own thing depending on the setting of ZAPP_PRINT_LOG, ! and the object/value passed in for 'priority'. We're abusing the ! priority argument to allow for logging to a REQUEST object ! attribute. ! ! If 'priority' is a requestLogger, it's used to log the message ! to a request property. (you can build a requestLogger by using ! the 'buildRequestLogger' function.) ! ! Otherwise it's assumed to be an integer, and the message is ! logged normally if the ZAPP_PRINT_LOG environment variable is ! not set, or it's simply "print"ed if it is set. ! ! """ ! ! if type(priority) == type({}) and priority.has_key(LOGINFOKEY): ! logInfo = priority.get(LOGINFOKEY,None) ! if logInfo is not None: ! logInfo.append(message) ! ! elif priority>INFO: if ZAPP_PRINT_LOG: print message |