#15917: Logging dictionary config works wrong at least with SMTPHandler
------------------------------------+------------------------------
               Reporter:  albenik   |          Owner:  nobody
                   Type:  Bug       |         Status:  reopened
              Milestone:            |      Component:  Core (Other)
                Version:  1.3       |       Severity:  Normal
             Resolution:            |       Keywords:
           Triage Stage:  Accepted  |      Has patch:  0
    Needs documentation:  0         |    Needs tests:  0
Patch needs improvement:  0         |  Easy pickings:  0
------------------------------------+------------------------------
Changes (by aaugustin):

 * stage:  Unreviewed => Accepted


Comment:

 OK, I was expected an exception, actually it's rather a silent
 misconfiguration. I confirm that `django.utils.log.dictConfig` with Python
 2.6 and `logging.config.dictConfig` in stock Python 2.7 behave
 differently.

 {{{
 >>> from django.utils.log import dictConfig   # Django
 >>> dictConfig({
 ...     'version': 1,
 ...     'handlers': {
 ...         'send_email': {
 ...             'class':'logging.handlers.SMTPHandler',
 ...             'mailhost': ('localhost', 25),
 ...             'fromaddr': 'dja...@example.com',
 ...             'toaddrs': ['dja...@example.com'],
 ...             'subject': 'oops!',
 ...             'credentials': ('root', 'root'),
 ...         },
 ...     },
 ...     'loggers': {
 ...         'django': {
 ...             'handlers':['send_email'],
 ...         },
 ...     },
 ... })
 >>> import logging
 >>> handler = logging.getLogger('django').handlers[0]
 >>> handler.mailhost
 ('localhost', 25)
 >>> handler.mailport
 >>> handler.username
 >>> handler.password
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 AttributeError: SMTPHandler instance has no attribute 'password'
 }}}

 {{{

 >>> from logging.config import dictConfig   # Python 2.7

 (snip - same commands as above)

 >>> handler.mailhost
 'localhost'
 >>> handler.mailport
 25
 >>> handler.username
 'root'
 >>> handler.password
 'root'
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15917#comment:3>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to