Changeset 4873 for waeup/trunk/src
- Timestamp:
- 22 Jan 2010, 12:49:37 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/datacenter.py
r4858 r4873 4 4 tools for importing/exporting CSV data. 5 5 """ 6 import logging 6 7 import os 7 8 import struct … … 19 20 grok.implements(IDataCenter) 20 21 storage = os.path.join(os.path.dirname(__file__), 'files') 22 23 @property 24 def logger(self): 25 """Get a logger for datacenter actions. 26 """ 27 # We need a different logger for every site... 28 site = grok.getSite() 29 sitename = site.__name__ 30 loggername = 'waeup.sirp.%s.datacenter' % sitename 31 logger = logging.getLogger(loggername) 32 if not logger.handlers: 33 logger = self._setupLogger(logger) 34 return logger 35 36 def _setupLogger(self, logger): 37 """Setup datacenter logger. 38 """ 39 logdir = os.path.join(self.storage, 'logs') 40 if not os.path.exists(logdir): 41 os.mkdir(logdir) 42 filename = os.path.join(logdir, 'datacenter.log') 43 44 # Create a rotating file handler logger for datacenter. 45 handler = logging.handlers.RotatingFileHandler( 46 filename, maxBytes=5*1024**1, backupCount=5) 47 formatter = logging.Formatter( 48 '%(asctime)s - %(levelname)s - %(message)s') 49 handler.setFormatter(formatter) 50 51 # Here we decide, whether our messages will _also_ go to 52 # application log. 53 logger.propagate = False 54 logger.addHandler(handler) 55 return logger 21 56 22 57 def getReceivers(self): … … 105 140 not_copied = copyFileSystemTree(self.storage, path, 106 141 overwrite=overwrite) 107 108 142 self.storage = path 109 143 return not_copied
Note: See TracChangeset for help on using the changeset viewer.