Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
pulling in support for settings_local.py
Browse files Browse the repository at this point in the history
  • Loading branch information
James Socol committed Feb 3, 2010
1 parent e6b201f commit 6fe3c3b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
27 changes: 27 additions & 0 deletions log_settings.py
@@ -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('dj')

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

26 changes: 21 additions & 5 deletions manage.py
@@ -1,11 +1,27 @@
#!/usr/bin/env python
from django.core.management import execute_manager
import site
from django.core.management import execute_manager, setup_environ

try:
import settings # Assumed to be in the same directory.
import settings_local as settings
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)

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)

0 comments on commit 6fe3c3b

Please sign in to comment.