Changeset 8492


Ignore:
Timestamp:
22 May 2012, 23:30:17 (13 years ago)
Author:
uli
Message:

Use DatedRotatingFileHandler? for logging.

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/setup.py

    r8418 r8492  
    3636    'zope.schema >= 3.8.0',
    3737    'zope.sendmail',
     38    'ulif.loghandlers',
    3839    ],
    3940
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/logger.py

    r7811 r8492  
    7777import logging
    7878from string import Template
     79from ulif.loghandlers import DatedRotatingFileHandler
    7980from zope import schema
    8081from zope.component import queryUtility
     
    8485from waeup.kofa.utils.helpers import get_current_principal
    8586
    86 #: Default logfile size (5 KB)
     87#: Default logfile size (5 KB, not relevant for DatedRotatingFileHandlers)
    8788MAX_BYTES = 5 * 1024 ** 2
    8889
    89 #: Default num of backup files (5)
    90 BACKUP_COUNT = 5
     90#: Default num of backup files (-1 = indefinite)
     91BACKUP_COUNT = -1
    9192
    9293#: Default logging level (`logging.INFO')
     
    212213
    213214        # 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)
    216217        handler.setLevel(LEVEL)
    217218        formatter = logging.Formatter(
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_logger.py

    r7811 r8492  
    162162        self.assertEqual(len(result.handlers), 1)
    163163        handler = result.handlers[0]
    164         self.assertEqual(handler.maxBytes, MAX_BYTES)
     164        #self.assertEqual(handler.maxBytes, MAX_BYTES)
    165165        self.assertEqual(handler.backupCount, BACKUP_COUNT)
    166166        self.assertTrue(result.propagate is False)
     
    254254        self.assertTrue(isinstance(
    255255                handler, logging.handlers.RotatingFileHandler))
    256         self.assertEqual(handler.maxBytes, MAX_BYTES)
     256        #self.assertEqual(handler.maxBytes, MAX_BYTES)
    257257        self.assertEqual(handler.backupCount, BACKUP_COUNT)
    258258        self.assertTrue(handler.baseFilename.endswith('logs/sample.log'))
Note: See TracChangeset for help on using the changeset viewer.