From 7c5f69392937bf9039c0a33471206b7a78faff7c Mon Sep 17 00:00:00 2001 From: Jeff Balogh Date: Mon, 24 Jan 2011 14:26:13 -0800 Subject: [PATCH] move z.timer to its own log file (bug 628356) --- log_settings.py | 20 ++++++++++++++++++-- settings.py | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/log_settings.py b/log_settings.py index d78af37be8..81818916f7 100644 --- a/log_settings.py +++ b/log_settings.py @@ -31,6 +31,12 @@ cfg = { 'format': '%s: [%%(REMOTE_ADDR)s] %s' % (settings.SYSLOG_TAG, base_fmt), }, + 'prod2': { + '()': commonware.log.Formatter, + 'datefmt': '%H:%M:%s', + 'format': '%s: [%%(REMOTE_ADDR)s] %s' % (settings.SYSLOG_TAG2, + base_fmt), + }, }, 'handlers': { 'console': { @@ -42,6 +48,11 @@ cfg = { 'facility': logging.handlers.SysLogHandler.LOG_LOCAL7, 'formatter': 'prod', }, + 'syslog2': { + '()': logging.handlers.SysLogHandler, + 'facility': logging.handlers.SysLogHandler.LOG_LOCAL7, + 'formatter': 'prod2', + }, 'null': { '()': NullHandler, }, @@ -64,11 +75,16 @@ cfg = { for key, value in settings.LOGGING.items(): cfg[key].update(value) + +USE_SYSLOG = settings.HAS_SYSLOG and not settings.DEBUG + +if USE_SYSLOG: + cfg['loggers']['z.timer']['handlers'] = ['syslog2'] + # Set the level and handlers for all loggers. for logger in cfg['loggers'].values() + [cfg['root']]: - syslog = settings.HAS_SYSLOG and not settings.DEBUG if 'handlers' not in logger: - logger['handlers'] = ['syslog' if syslog else 'console'] + logger['handlers'] = ['syslog' if USE_SYSLOG else 'console'] if 'level' not in logger: logger['level'] = settings.LOG_LEVEL if logger is not cfg['root'] and 'propagate' not in logger: diff --git a/settings.py b/settings.py index 4e0ba542c6..8913a2f0a0 100644 --- a/settings.py +++ b/settings.py @@ -618,6 +618,7 @@ HERA = [{'USERNAME': '', LOG_LEVEL = logging.DEBUG HAS_SYSLOG = True # syslog is used if HAS_SYSLOG and NOT DEBUG. SYSLOG_TAG = "http_app_addons" +SYSLOG_TAG2 = "http_app_addons2" # See PEP 391 and log_settings.py for formatting help. Each section of # LOGGING will get merged into the corresponding section of # log_settings.py. Handlers and log levels are set up automatically based