summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-09-26 19:56:21 +0200
committerClaude Paroz <claude@2xlibre.net>2012-09-29 22:56:18 +0200
commitf0f327bbfe1caae6d11fbe20a3b5b96eed1704cf (patch)
treeedcbac875f1a315aed4fa4a99031291d484fafa5 /django
parenta014ddfef2f606471f25c756d97b3b50fcbd9e91 (diff)
Fixed #18993 -- 'django' logger logs to console when DEBUG=True
Thanks Preston Holmes for the review.
Diffstat (limited to 'django')
-rw-r--r--django/utils/log.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/django/utils/log.py b/django/utils/log.py
index c111512fe8..9e07961221 100644
--- a/django/utils/log.py
+++ b/django/utils/log.py
@@ -24,18 +24,25 @@ except ImportError:
getLogger = logging.getLogger
-# Default logging for Django. This sends an email to
-# the site admins on every HTTP 500 error. All other log
-# records are sent to the bit bucket.
+# Default logging for Django. This sends an email to the site admins on every
+# HTTP 500 error. Depending on DEBUG, all other log records are either sent to
+# the console (DEBUG=True) or discarded by mean of the NullHandler (DEBUG=False).
DEFAULT_LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
- }
+ },
+ 'require_debug_true': {
+ '()': 'django.utils.log.RequireDebugTrue',
+ },
},
'handlers': {
+ 'console':{
+ 'level': 'INFO',
+ 'class': 'logging.StreamHandler',
+ },
'null': {
'class': 'django.utils.log.NullHandler',
},
@@ -47,12 +54,13 @@ DEFAULT_LOGGING = {
},
'loggers': {
'django': {
- 'handlers': ['null'],
+ 'handlers': ['console'],
+ 'filters': ['require_debug_true'],
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
- 'propagate': True,
+ 'propagate': False,
},
}
}
@@ -130,3 +138,8 @@ class CallbackFilter(logging.Filter):
class RequireDebugFalse(logging.Filter):
def filter(self, record):
return not settings.DEBUG
+
+
+class RequireDebugTrue(logging.Filter):
+ def filter(self, record):
+ return settings.DEBUG