Skip to content
This repository
tree: 217c599e2c
Fetching contributors…

Cannot retrieve contributors at this time

file 28 lines (22 sloc) 0.868 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
import logging
import logging.handlers

from django.conf import settings


# Loggers created under the "z" namespace, e.g. "z.caching", will inherit the
# configuration from the base z logger.
log = logging.getLogger('z')

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)

log.setLevel(level)
handler.setLevel(level)
handler.setFormatter(formatter)
log.addHandler(handler)
Something went wrong with that request. Please try again.