Changeset 4874 for waeup/trunk/src
- Timestamp:
- 22 Jan 2010, 12:49:57 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/app.py
r4789 r4874 1 1 import grok 2 import logging 3 import os 2 4 from zope.app.authentication.authentication import PluggableAuthentication 3 5 from zope.app.security.interfaces import IAuthentication … … 18 20 PluggableAuthentication, provides = IAuthentication, 19 21 setup = setup_authentication) 22 23 @property 24 def logger(self): 25 sitename = self.__name__ 26 loggername = 'waeup.sirp.%s' % sitename 27 logger = logging.getLogger(loggername) 28 if not logger.handlers: 29 logger = self._setupLogger(logger) 30 return logger 31 20 32 21 33 def __init__(self, name=u'Sample University', **kw): … … 30 42 self['users'] = UserContainer() 31 43 self['datacenter'] = DataCenter() 44 45 def _setupLogger(self, logger): 46 """Setup general application logger. 47 48 The logfile will be stored in the datacenter logs/ dir. 49 """ 50 logdir = os.path.join(self['datacenter'].storage, 'logs') 51 if not os.path.exists(logdir): 52 os.mkdir(logdir) 53 filename = os.path.join(logdir, 'application.log') 54 55 # Create a rotating file handler logger for application. 56 handler = logging.handlers.RotatingFileHandler( 57 filename, maxBytes=5*1024**1, backupCount=7) 58 formatter = logging.Formatter( 59 '%(asctime)s - %(levelname)s - %(message)s') 60 handler.setFormatter(formatter) 61 62 # Don't send log msgs to ancestors. This stops displaying 63 # logmessages on the commandline. 64 logger.propagate = False 65 logger.addHandler(handler) 66 return logger
Note: See TracChangeset for help on using the changeset viewer.