Changeset 9769 for main


Ignore:
Timestamp:
5 Dec 2012, 08:32:11 (12 years ago)
Author:
Henrik Bettermann
Message:

Ease customization of logging format. We use this for the new payments logger.

Do not show payments.log on logfile search page.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/datacenter.py

    r9589 r9769  
    116116        """Get the files from logs/ subdir. Files are sorted by name.
    117117
    118         By default backup logs ('app.log.1', etc.) are excluded.
     118        By default backup logs ('app.log.1', etc.) and payments.log
     119        are excluded.
    119120        """
    120121        result = []
     
    124125        for name in sorted(os.listdir(logdir)):
    125126            if not os.path.isfile(os.path.join(logdir, name)):
     127                continue
     128            if name == 'payments.log':
    126129                continue
    127130            if exclude_backups == True and RE_LOGFILE_BACKUP_NAME.match(name):
  • main/waeup.kofa/trunk/src/waeup/kofa/payments/payment.py

    r9505 r9769  
    3131    payment_states)
    3232from waeup.kofa.utils.helpers import attrs_to_fields, get_current_principal
     33from waeup.kofa.utils.logger import Logger
    3334
    34 class Payment(grok.Container):
     35class Payment(grok.Container, Logger):
    3536    """This is a payment.
    3637    """
     
    3839    grok.provides(IPayment)
    3940    grok.baseclass()
     41
     42    logger_name = 'waeup.kofa.${sitename}.payments'
     43    logger_filename = 'payments.log'
     44    logger_format_str = '"%(asctime)s","%(user)s",%(message)s'
     45
     46    def logger_info(self, comment=None):
     47        """Get the logger's info method.
     48        """
     49        self.logger.info('%s' % comment)
     50        return
    4051
    4152    def __init__(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/logger.py

    r8608 r9769  
    157157    #: replaced by the actual used site name.
    158158    logger_name = 'waeup.kofa.${sitename}'
     159
     160    #: The format to use when logging.
     161    logger_format_str = '%(asctime)s - %(levelname)s - %(user)s - %(message)s'
     162
    159163    implements(ILogger)
    160164
     
    214218            filename, when='MON', backupCount=BACKUP_COUNT)
    215219        handler.setLevel(LEVEL)
    216         formatter = logging.Formatter(
    217             '%(asctime)s - %(levelname)s - %(user)s - %(message)s')
     220        formatter = logging.Formatter(self.logger_format_str)
    218221        handler.setFormatter(formatter)
    219222
Note: See TracChangeset for help on using the changeset viewer.