Changeset 6444 for main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Timestamp:
- 21 Jun 2011, 00:52:54 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py
r6392 r6444 23 23 The root for applicants. 24 24 """ 25 import logging26 25 import grok 27 import os28 26 from hurry.query import Eq 29 27 from hurry.query.interfaces import IQuery 30 28 from zope.component import getUtility 31 29 from waeup.sirp.interfaces import IWAeUPSIRPPluggable 30 from waeup.sirp.utils.logger import ISiteLoggers 32 31 from waeup.sirp.applicants.interfaces import IApplicantsRoot 33 32 … … 44 43 """Get a logger for applicants. 45 44 """ 46 # We need a different logger for every site... 47 site = grok.getSite() 48 sitename = getattr(site, '__name__', 'app') 49 loggername = 'waeup.sirp.%s.applicants' % sitename 50 logger = logging.getLogger(loggername) 51 if not logger.handlers: 52 logger = self._setupLogger(logger) 53 return logger 54 55 def _setupLogger(self, logger): 56 """Setup applicants logger. 57 """ 58 logdir = os.path.join(grok.getSite()['datacenter'].storage, 'logs') 59 if not os.path.exists(logdir): 60 os.mkdir(logdir) 61 filename = os.path.join(logdir, 'applicants.log') 62 63 # Create a rotating file handler logger for datacenter. 64 handler = logging.handlers.RotatingFileHandler( 65 filename, maxBytes=5*1024**1, backupCount=5) 66 formatter = logging.Formatter( 67 '%(asctime)s - %(levelname)s - %(message)s') 68 handler.setFormatter(formatter) 69 70 # Here we decide, whether our messages will _also_ go to 71 # application log. 72 logger.propagate = False 73 logger.setLevel(logging.DEBUG) 74 logger.addHandler(handler) 75 return logger 76 45 loggers = getUtility(ISiteLoggers).getLoggers() 46 if 'waeup.sirp.%s.applicants' not in loggers.keys(): 47 loggers.register('waeup.sirp.%s.applicants') 48 return loggers.getLogger('waeup.sirp.%s.applicants') 77 49 78 50 class ApplicantsPlugin(grok.GlobalUtility):
Note: See TracChangeset for help on using the changeset viewer.