#14616: Recommend a leading underscore on module-level loggers in docs
---------------------------+------------------------------------------------
 Reporter:  dgolden_ichec  |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Documentation  |     Version:  SVN       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 The [http://docs.djangoproject.com/en/dev/topics/logging/#naming-loggers
 in-development django logging docs], at least at time of writing, suggest
 using {{{"logger"}}} for module-level logger instances.   That is
 problematic - consider people doing {{{"from blah import *"}}} and
 accidentally grabbing the "wrong" logger instance.  Using a leading
 underscore on such module-level loggers
 [http://www.google.com/search?q=%22_log+%3D+logging.getLogger%28__name__%29%22
 is therefore common in pythonland] i.e.

 {{{
 #!python
 _log = logging.getLogger(__name__)
 }}}

 While this is ultimately just a python quirk, I suggest the docs should be
 trivially amended to recommend a leading underscore (e.g. {{{"_log"}}})
 convention rather than {{{"logger"}}}, possibly with a very brief
 explanation as to why, for beginner-friendliness. Mistakenly importing
 another module's logger leads to quite confusing logging behaviour.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14616>
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-upda...@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