now we can all be lumberjacks
This commit is contained in:
Родитель
93e774be22
Коммит
b2c42219d7
|
@ -0,0 +1,27 @@
|
|||
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')
|
||||
|
||||
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:
|
||||
handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter(fmt, datefmt='%H:%M:%S')
|
||||
else:
|
||||
level = getattr(settings, 'LOG_LEVEL', level)
|
||||
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)
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
import site
|
||||
|
||||
from django.core.management import execute_manager
|
||||
from django.core.management import execute_manager, setup_environ
|
||||
|
||||
|
||||
try:
|
||||
|
@ -20,6 +20,13 @@ except ImportError:
|
|||
site.addsitedir(settings.path('apps'))
|
||||
site.addsitedir(settings.path('lib'))
|
||||
|
||||
# The first thing execute_manager does is call `setup_environ`. Logging config
|
||||
# needs to access settings, so we'll setup the environ early.
|
||||
setup_environ(settings)
|
||||
|
||||
# Import for side-effect: configures our logging handlers.
|
||||
import log_settings
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
execute_manager(settings)
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# Django settings for zamboni project.
|
||||
|
||||
# Make filepaths relative to settings.
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
||||
# Make filepaths relative to settings.
|
||||
ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||
path = lambda *a: os.path.join(ROOT, *a)
|
||||
|
||||
|
@ -101,3 +104,5 @@ INSTALLED_APPS = (
|
|||
)
|
||||
|
||||
TEST_RUNNER = 'django_nose.run_tests'
|
||||
|
||||
LOG_LEVEL = logging.DEBUG
|
||||
|
|
Загрузка…
Ссылка в новой задаче