Changeset 8492 for main/waeup.kofa/trunk/src
- Timestamp:
- 22 May 2012, 23:30:17 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/logger.py
r7811 r8492 77 77 import logging 78 78 from string import Template 79 from ulif.loghandlers import DatedRotatingFileHandler 79 80 from zope import schema 80 81 from zope.component import queryUtility … … 84 85 from waeup.kofa.utils.helpers import get_current_principal 85 86 86 #: Default logfile size (5 KB )87 #: Default logfile size (5 KB, not relevant for DatedRotatingFileHandlers) 87 88 MAX_BYTES = 5 * 1024 ** 2 88 89 89 #: Default num of backup files ( 5)90 BACKUP_COUNT = 590 #: Default num of backup files (-1 = indefinite) 91 BACKUP_COUNT = -1 91 92 92 93 #: Default logging level (`logging.INFO') … … 212 213 213 214 # Create a rotating file handler logger. 214 handler = logging.handlers.RotatingFileHandler(215 filename, maxBytes=MAX_BYTES, backupCount=BACKUP_COUNT)215 handler = DatedRotatingFileHandler( 216 filename, when='MON', backupCount=BACKUP_COUNT) 216 217 handler.setLevel(LEVEL) 217 218 formatter = logging.Formatter( -
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_logger.py
r7811 r8492 162 162 self.assertEqual(len(result.handlers), 1) 163 163 handler = result.handlers[0] 164 self.assertEqual(handler.maxBytes, MAX_BYTES)164 #self.assertEqual(handler.maxBytes, MAX_BYTES) 165 165 self.assertEqual(handler.backupCount, BACKUP_COUNT) 166 166 self.assertTrue(result.propagate is False) … … 254 254 self.assertTrue(isinstance( 255 255 handler, logging.handlers.RotatingFileHandler)) 256 self.assertEqual(handler.maxBytes, MAX_BYTES)256 #self.assertEqual(handler.maxBytes, MAX_BYTES) 257 257 self.assertEqual(handler.backupCount, BACKUP_COUNT) 258 258 self.assertTrue(handler.baseFilename.endswith('logs/sample.log'))
Note: See TracChangeset for help on using the changeset viewer.