This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pulling in support for settings_local.py
- Loading branch information
James Socol
committed
Feb 3, 2010
1 parent
e6b201f
commit 6fe3c3b
Showing
2 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |