Changeset 6348 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 11 Jun 2011, 10:52:50 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicants.py
r6347 r6348 47 47 IWorkflowInfo(self).fireTransition('init') 48 48 return 49 50 def getApplicantsRootLogger(self): 51 return grok.getSite()['applicants'].logger 49 52 50 53 @property -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r6336 r6348 61 61 from waeup.sirp.applicants.workflow import create_workflow, INITIALIZED, STARTED 62 62 63 64 63 results_widget = CustomWidgetFactory( 65 64 WAeUPObjectWidget, ResultEntry) … … 570 569 IWorkflowInfo(self.context).fireTransition(transition_id) 571 570 self.flash('Form has been saved.') 571 self.context.getApplicantsRootLogger().info('Saved') 572 572 return 573 573 -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
r6343 r6348 297 297 state = Attribute('Returns the application state of an applicant') 298 298 299 def getApplicantsRootLogger(): 300 """Returns the logger from the applicants root object 301 """ 302 299 303 reg_no = schema.TextLine( 300 304 title = u'JAMB Registration Number', -
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.