Add SYSLOG_FORMAT setting
This commit is contained in:
Родитель
afc992aeb6
Коммит
b5a7dd606a
|
@ -32,6 +32,12 @@ tree. It sets up sensible defaults, but you can twiddle with these settings:
|
|||
default in ``log_settings.py``. The complete list of formatting options is
|
||||
available at http://docs.python.org/library/logging.html#formatter.
|
||||
|
||||
``SYSLOG_FORMAT``
|
||||
This setting is the same as ``LOG_FORMAT`` except it controls the format for
|
||||
what is sent to syslog. By default, it's the same as ``LOG_FORMAT`` except
|
||||
it strips the date/time prefix since syslogd is going to timestamp
|
||||
everything anyway.
|
||||
|
||||
|
||||
Using Loggers
|
||||
-------------
|
||||
|
|
|
@ -8,14 +8,16 @@ from django.conf import settings
|
|||
# configuration from the base z logger.
|
||||
log = logging.getLogger('z')
|
||||
|
||||
fmt = '%(asctime)s %(name)s:%(levelname)s %(message)s :%(pathname)s:%(lineno)s'
|
||||
fmt = getattr(settings, 'LOG_FORMAT', fmt)
|
||||
level = settings.LOG_LEVEL
|
||||
|
||||
if settings.DEBUG:
|
||||
fmt = '%(asctime)s %(name)s:%(levelname)s %(message)s :%(pathname)s:%(lineno)s'
|
||||
fmt = getattr(settings, 'LOG_FORMAT', fmt)
|
||||
handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter(fmt, datefmt='%H:%M:%S')
|
||||
else:
|
||||
fmt = '%(name)s:%(levelname)s %(message)s :%(pathname)s:%(lineno)s'
|
||||
fmt = getattr(settings, 'SYSLOG_FORMAT', fmt)
|
||||
SysLogger = logging.handlers.SysLogHandler
|
||||
handler = SysLogger(facility=SysLogger.LOG_LOCAL7)
|
||||
formatter = logging.Formatter(fmt)
|
||||
|
|
Загрузка…
Ссылка в новой задаче