[Django] #18773: Enable optional logging of invalid variable lookups

21 views
Skip to first unread message

Django

unread,
Aug 15, 2012, 10:36:19 PM8/15/12
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
---------------------------------+--------------------
Reporter: wrigley | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
Adding something like
{{{
# django/template/base.py
if getattr(settings,'TEMPLATE_LOG_IF_INVALID', False):
logging.getLogger(settings.TEMPLATE_LOG_IF_INVALID).debug(
"Failed lookup for key in [%s] in %r" %(bit,current))
}}}
around line 763, or whenever the silent_variable_failure is tested or
something, would be awesome! That way there would be an easy way to check
for invalid variables in the templates without compromising neither
adminpages, layout or page reliability.

Then you could use something like:
{{{
# settings.py
TEMPLATE_LOG_IF_INVALID = 'invalid_log'

LOGGING = {
'version': 1,
'handlers': {
'console': {
'class': 'logger.StreamHandler',
'level': 'DEBUG'
}
},
'loggers': {
'invalid_log': {
'handlers': 'console',
'level': 'DEBUG'
}
}
}
}}}
a loglevel of WARNING might be more appropriate, but I'll leave that
decision up to you guys, seeing as I am new to django and don't know
neither the code base nor the conventions too well yet.

Cheers,
/J

--
Ticket URL: <https://code.djangoproject.com/ticket/18773>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 16, 2012, 4:07:31 AM8/16/12
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
---------------------------------+------------------------------------
Reporter: wrigley | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by claudep):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:1>

Django

unread,
Apr 14, 2014, 5:44:28 PM4/14/14
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
Type: New feature | CarolineSimpson
Component: Template system | Status: assigned
Severity: Normal | Version: 1.4
Keywords: | Resolution:
Has patch: 1 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by CarolineSimpson):

* status: new => assigned
* owner: nobody => CarolineSimpson
* has_patch: 0 => 1


Comment:

I've submitted a pull request for this issue:
https://github.com/django/django/pull/2552

Added a new logger, and log when there is an exception in the resolve
function. The logger uses the null handler by default.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:2>

Django

unread,
Apr 15, 2014, 5:21:13 PM4/15/14
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
Type: New feature | CarolineSimpson
Component: Template system | Status: assigned
Severity: Normal | Version: 1.4
Keywords: | Resolution:
Has patch: 1 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by CarolineSimpson):

The pull request has been updated to include the template name in the
output.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:3>

Django

unread,
Aug 13, 2014, 2:15:38 PM8/13/14
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
Type: New feature | CarolineSimpson
Component: Template system | Status: assigned
Severity: Normal | Version: 1.4
Keywords: | Resolution:
Has patch: 1 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 1
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

I left comments for improvement on the PR. Please uncheck "Patch needs
improvement" when you update it, thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:4>

Django

unread,
Jan 17, 2015, 1:41:20 PM1/17/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned

Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by CarolineSimpson):

* needs_better_patch: 1 => 0


Comment:

I have submitted a new pull request with the updates requested for the
previous pull request.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:5>

Django

unread,
Jan 18, 2015, 1:03:52 PM1/18/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned
Component: Template system | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by CarolineSimpson):

I've updated the pull request with fixes from review feedback.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:6>

Django

unread,
Jan 19, 2015, 4:49:07 AM1/19/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned
Component: Template system | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by berkerpeksag):

* version: 1.4 => master


--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:7>

Django

unread,
Mar 14, 2015, 6:51:47 PM3/14/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

Reviewed PR & needs a rebase.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:8>

Django

unread,
Mar 15, 2015, 4:08:32 PM3/15/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by CarolineSimpson):

* needs_better_patch: 1 => 0


Comment:

I've updated the patch and done a rebase.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:9>

Django

unread,
Mar 15, 2015, 7:50:02 PM3/15/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by CarolineSimpson):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:10>

Django

unread,
Mar 27, 2015, 10:27:44 AM3/27/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0

* stage: Accepted => Ready for checkin


Comment:

Looks good, pending some minor cosmetic changes.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:11>

Django

unread,
Mar 27, 2015, 2:48:33 PM3/27/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by CarolineSimpson):

The latest review changes are now incorporated into the patch as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:12>

Django

unread,
Mar 27, 2015, 7:25:46 PM3/27/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: closed

Component: Template system | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"dc5b01ad05e50ccde688c73c2ed3334a956076b0" dc5b01a]:
{{{
#!CommitTicketReference repository=""
revision="dc5b01ad05e50ccde688c73c2ed3334a956076b0"
Fixed #18773 -- Added logging for template variable resolving

Added a django.template logger without a default handler. Added
logging if there is an exception while resolving variables in a
template.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:13>

Django

unread,
Sep 21, 2015, 7:32:14 PM9/21/15
to django-...@googlegroups.com
#18773: Enable optional logging of invalid variable lookups
-------------------------------------+-------------------------------------
Reporter: wrigley | Owner:
| CarolineSimpson
Type: New feature | Status: closed
Component: Template system | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"85c52743f7b99ac6575d87080a9ffb7540acbf18" 85c52743]:
{{{
#!CommitTicketReference repository=""
revision="85c52743f7b99ac6575d87080a9ffb7540acbf18"
Refs #18773 -- Improved template variable exception logging message.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18773#comment:14>

Reply all
Reply to author
Forward
0 new messages