This commit is contained in:
Wil Clouser 2010-03-12 22:02:27 -08:00
Родитель afc992aeb6
Коммит b5a7dd606a
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -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)