Changeset 6348 for main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py
- Timestamp:
- 11 Jun 2011, 10:52:50 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py
r6198 r6348 23 23 The root for applicants. 24 24 """ 25 import logging 25 26 import grok 27 import os 26 28 from hurry.query import Eq 27 29 from hurry.query.interfaces import IQuery … … 36 38 """ 37 39 grok.implements(IApplicantsRoot) 40 41 @property 42 def logger(self): 43 """Get a logger for applicants. 44 """ 45 # We need a different logger for every site... 46 site = grok.getSite() 47 sitename = getattr(site, '__name__', 'app') 48 loggername = 'waeup.sirp.%s.applicants' % sitename 49 logger = logging.getLogger(loggername) 50 if not logger.handlers: 51 logger = self._setupLogger(logger) 52 return logger 53 54 def _setupLogger(self, logger): 55 """Setup applicants logger. 56 """ 57 logdir = os.path.join(grok.getSite()['datacenter'].storage, 'logs') 58 if not os.path.exists(logdir): 59 os.mkdir(logdir) 60 filename = os.path.join(logdir, 'applicants.log') 61 62 # Create a rotating file handler logger for datacenter. 63 handler = logging.handlers.RotatingFileHandler( 64 filename, maxBytes=5*1024**1, backupCount=5) 65 formatter = logging.Formatter( 66 '%(asctime)s - %(levelname)s - %(message)s') 67 handler.setFormatter(formatter) 68 69 # Here we decide, whether our messages will _also_ go to 70 # application log. 71 logger.propagate = False 72 logger.setLevel(logging.DEBUG) 73 logger.addHandler(handler) 74 return logger 38 75 39 76 @property
Note: See TracChangeset for help on using the changeset viewer.