On Tue, Sep 29, 2009 at 4:36 AM, Vinay Sajip <vinay_sa...@yahoo.co.uk> wrote:
>
>
>
> On Sep 17, 9:25 am, Simon Willison <si...@simonwillison.net> wrote:
>> Problems and challenges
>> =======================
>>
>> 1. The Python logging module isn't very nicely designed - its Java
>> heritage shines through, and things like logging.basicConfig behave in
>> unintuitive ways (if you call basicConfig twice the second call fails
>> silently but has no effect). This is why I suggest wrapping it in our
>> own higher level interface.
>
> Simon, I'm the author of Python's logging package. Sorry for the delay
> in replying, I've been away from this list awhile. I think the "Java
> heritage shines through" is just FUD. basicConfig's behaviour is fully
> documented here:
>
> http://docs.python.org/library/logging.html#logging.basicConfig
>
> Including the fact that it sometimes (by design) has no effect.
>
> There are a lot of people for whom logging just means writing to a
> file, and that's why they have difficulty understanding why logging is
> designed as it is. I would suggest you take a quick look at
>
> http://plumberjack.blogspot.com/2009/09/python-logging-101.html
>
> and then tell me why you think Python logging isn't well designed for
> its purpose. You can do basic logging with two lines of setup (one
> line if you ignore the import):
>
> import logging
> logging.basicConfig(level=logging.DEBUG,filename='/path/to/my/log',
> format='%(asctime)s %(message)s')
>
> and then
>
> logging.getLogger(__name__).debug("Just checking this works")
>
> Not too sure where the Java heritage is there, or where the hard part
> is.
>

The hard part is that basicConfig only works like that back to Python
2.4 yet Django supports 2.3. When I added logging to Python-Markdown,
this was the hardest part. Figuring out how to configure logging so
that it works in 2.3 as well. The documentation is not exactly helpful
in that regard.

In fact, it was for this very reason that we added our own wrapper
around logging. It didn't seem reasonable for our users to go through
the same pain that we did. Sure we got a few things wrong at first,
but with the help of a few people in the community we worked those out
and our wrapper seems to work ok now. Yes - ok - I get the sense it
could be better.

Ever since then, any mention of logging leaves a bad taste in my
mouth. Perhaps if I was working only in 2.6 or such, this wouldn't be
an issue, but we have promised support back to 2.3.

Of course, it is possible that I'm missing something obvious.

-- 
----
\X/ /-\ `/ |_ /-\ |\|
Waylan Limberg

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

Reply via email to