Permalink
Browse files

Revert "[Bug 750247] Use dictConfig logging configuration"

This reverts commit c5cf92f.

We'll unrevert once IT sets up the settings_local.py properly.
  • Loading branch information...
1 parent 4a66185 commit 5a16755a2255e1b60ce30a18b7fbf626db830666 @rlr rlr committed Oct 4, 2012
Showing with 40 additions and 41 deletions.
  1. +36 −0 log_settings.py
  2. +3 −0 manage.py
  3. +1 −41 settings.py
View
36 log_settings.py
@@ -0,0 +1,36 @@
+import logging
+import logging.handlers
+
+from django.conf import settings
+
+import celery.conf
+import celery.log
+
+
+# Loggers created under the "z" namespace, e.g. "z.caching", will inherit the
+# configuration from the base z logger.
+log = logging.getLogger('k')
+
+fmt = ('%s: %%(asctime)s %%(name)s:%%(levelname)s %%(message)s '
+ ':%%(pathname)s:%%(lineno)s' % settings.SYSLOG_TAG)
+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:
+ 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)
+
+if not settings.DEBUG:
+ task_log = logging.getLogger('k.celery')
+ task_proxy = celery.log.LoggingProxy(task_log)
+ celery.conf.CELERYD_LOG_FILE = task_proxy
+ celery.conf.CELERYD_LOG_COLOR = False
View
3 manage.py
@@ -49,6 +49,9 @@
import session_csrf
session_csrf.monkeypatch()
+# Import for side-effect: configures our logging handlers.
+import log_settings
+
if __name__ == "__main__":
execute_manager(settings)
View
42 settings.py
@@ -1,58 +1,18 @@
# Django settings for kitsune project.
from datetime import date
import logging
-import logging.handlers
import os
import platform
-import celery
-
from sumo_locales import LOCALES
DEBUG = True
TEMPLATE_DEBUG = DEBUG
STAGE = False
+LOG_LEVEL = logging.INFO
SYSLOG_TAG = 'http_sumo_app'
-# This logging configuration can be modified in settings_local.py
-# Format documentation: http://docs.python.org/library/logging.config.html
-LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': True,
- 'formatters': {
- 'default': {
- 'format': '{0}: %(asctime)s %(name)s:%(levelname)s %(message)s: '
- '%(pathname)s:%(lineno)s'.format(SYSLOG_TAG),
- 'datefmt': '%H:%M:%S' if DEBUG else None,
- }
- },
- 'handlers': {
- 'syslog': {
- 'class': 'logging.handlers.SysLogHandler',
- 'formatter': 'default',
- 'facility': logging.handlers.SysLogHandler.LOG_LOCAL7,
- },
- 'console': {
- 'class': 'logging.StreamHandler',
- 'formatter': 'default',
- },
- },
- 'loggers': {
- 'k': {
- 'handlers': ['console' if DEBUG else 'syslog'],
- 'propogate': True,
- 'level': logging.INFO,
- }
- },
-}
-
-if not DEBUG:
- task_log = logging.getLogger('k.celery')
- task_proxy = celery.log.LoggingProxy(task_log)
- celery.conf.CELERYD_LOG_FILE = task_proxy
- celery.conf.CELERYD_LOG_COLOR = False
-
ROOT = os.path.dirname(os.path.abspath(__file__))
path = lambda *a: os.path.join(ROOT, *a)

0 comments on commit 5a16755

Please sign in to comment.