Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added catch-all logger and tweaked output formats. #787

Closed
wants to merge 3 commits into from

4 participants

@danielsokolowski

Having a default catch-all logger will prevent '[Sat Feb 23 12:17:35 2013] [error] No handlers could be found for logger " <name>"' Apache log errors. Updated the 'simple' and 'verbose' format to something more useful in my opinion:

Before log 'simple:
WARNING User 'support3' attempted to register with company 'KL Insight2' but it already exists

After log 'simple': 
WARNING accounts.forms forms.py@82: User 'support3' attempted to register with company 'KL Insight2' but it already exists

Before log 'verbose'
WARNING 2013-02-23 12:46:01,605 forms 22360 -1250423952 User 'support3' attempted to register with company 'KL Insight 2' but it already exists

After log 'verbose':
WARNING accounts.forms 2013-02-23 12:41:13,836 forms 22335 -1250423952 /srv/www/django/sample-site/src/django-project/accounts/forms.py@82: User 'support3' attempted to register with company 'KL Insight2' but it already exists

Thoughts?

claudep and others added some commits
@claudep claudep Minor cleanups in templates test imports 335a060
@HonzaKral HonzaKral Merge pull request #781 from zsiciarz/ticket_19854
Fixed #19854 -- Added test runner option to skip Selenium tests
a05ab44
@danielsokolowski danielsokolowski Added catch-all logger and tweaked output formats.
Having a default catch-all logger will prevent '[Sat Feb 23 12:17:35 2013] [error] No handlers could be found for logger "<__name__>"' errors. Updated the 'simple' and 'verbose' format to something more useful in my opinion:

Apache log 'simple': 
[Sat Feb 23 12:38:08 2013] [error] WARNING accounts.forms forms.py@82: User 'support3' attempted to register with company 'KL Insight2' but it already exists

Apache log 'verbose':
[Sat Feb 23 12:41:13 2013] [error] WARNING accounts.forms 2013-02-23 12:41:13,836 forms 22335 -1250423952 /srv/www/django/development.yupifoods.com/src/django-project/accounts/forms.py@82: User 'support3' attempted to register with company 'KL Insight2' but it already exists

Thoughts?
e8ced9b
@timgraham
Owner

A trac ticket would be helpful to get a discussion going.

@timgraham
Owner

Closing this in absence of an accepted trac ticket.

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2013
  1. @claudep
  2. @HonzaKral

    Merge pull request #781 from zsiciarz/ticket_19854

    HonzaKral authored
    Fixed #19854 -- Added test runner option to skip Selenium tests
  3. @danielsokolowski

    Added catch-all logger and tweaked output formats.

    danielsokolowski authored
    Having a default catch-all logger will prevent '[Sat Feb 23 12:17:35 2013] [error] No handlers could be found for logger "<__name__>"' errors. Updated the 'simple' and 'verbose' format to something more useful in my opinion:
    
    Apache log 'simple': 
    [Sat Feb 23 12:38:08 2013] [error] WARNING accounts.forms forms.py@82: User 'support3' attempted to register with company 'KL Insight2' but it already exists
    
    Apache log 'verbose':
    [Sat Feb 23 12:41:13 2013] [error] WARNING accounts.forms 2013-02-23 12:41:13,836 forms 22335 -1250423952 /srv/www/django/development.yupifoods.com/src/django-project/accounts/forms.py@82: User 'support3' attempted to register with company 'KL Insight2' but it already exists
    
    Thoughts?
This page is out of date. Refresh to see the latest.
View
9 docs/topics/logging.txt
@@ -249,10 +249,10 @@ complex logging setup, configured using :func:`logging.config.dictConfig`::
'disable_existing_loggers': True,
'formatters': {
'verbose': {
- 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
+ 'format': '%(levelname)s %(name)s %(asctime)s %(module)s %(process)d %(thread)d %(pathname)s@%(lineno)s: %(message)s'
},
'simple': {
- 'format': '%(levelname)s %(message)s'
+ 'format': '%(levelname)s %(name)s %(filename)s@%(lineno)s: %(message)s'
},
},
'filters': {
@@ -278,6 +278,11 @@ complex logging setup, configured using :func:`logging.config.dictConfig`::
}
},
'loggers': {
+ # Default catch-all logger ex. will catch any 'logger = logging.getLogger(__name__)'
+ '': {
+ 'handlers': ['console'],
+ 'level': 'INFO',
+ },
'django': {
'handlers': ['null'],
'propagate': True,
View
8 tests/regressiontests/templates/tests.py
@@ -19,10 +19,9 @@
from urlparse import urljoin
from django import template
-from django.template import (base as template_base, Context, RequestContext,
- Template)
from django.core import urlresolvers
-from django.template import loader
+from django.template import (base as template_base, loader, Context,
+ RequestContext, Template, TemplateSyntaxError)
from django.template.loaders import app_directories, filesystem, cached
from django.test import RequestFactory, TestCase
from django.test.utils import (setup_test_template_loader,
@@ -365,8 +364,6 @@ def test_token_smart_split(self):
@override_settings(SETTINGS_MODULE=None, TEMPLATE_DEBUG=True)
def test_url_reverse_no_settings_module(self):
# Regression test for #9005
- from django.template import Template, Context
-
t = Template('{% url will_not_match %}')
c = Context()
with self.assertRaises(urlresolvers.NoReverseMatch):
@@ -417,7 +414,6 @@ def test_no_wrapped_exception(self):
def test_invalid_block_suggestion(self):
# See #7876
- from django.template import Template, TemplateSyntaxError
try:
t = Template("{% if 1 %}lala{% endblock %}{% endif %}")
except TemplateSyntaxError as e:
Something went wrong with that request. Please try again.