>>
>> I personally consider what Chris reports to be "expected behaviour"
>
> We may be getting into personal preference here. I would NOT expect to
> see a library's debug output when running my script (or application).
> If that behavior/behaviour  were to be common, one would end up seeing
> debug output from indirect library dependencies. E.g. script uses
> "wonder_lib", which in turn uses "super_lib" and "awesome_lib", etc.
> One has the potential to see output from 3 libraries (or more if they
> also includes more libs), all 3 would need to be turned off in my
> script! :-(

Oh, absolutely, if I hadn't turned them on, sure.

The way the major java logging frameworks work, is that if you don't configure 
any logging, nothing at all happens.  If you use a  compatible [1] logging 
framework in your app, then the logging that comes out is completely dependent 
on what you set up in the logging.  Without any config, there is no logging. 
If you configure the top level root logger to be debug, then yes, you start 
getting debug from each and every and all and sundry library in use.  The 
normal 
idea is to set the root logger to say, WARN, and then turn on INFO/DEBUG for 
your own application code.

I think the difference is that if you don't do any config at all with python 
logging, it turns on a basic logger at DEBUG.

Actually, I went off and hacked up some example code, showing the two different 
ways of using logging with libraries that also use logging.  One, where 
libraries are not seen until asked for explicitly, and one, where libraries are 
seen until asked to be silent.  (And a few other cases)

https://github.com/karlp/python-logging-examples

Of course, now I'm even further away from knowing what exactly Wander was 
changing in which direction :)  Looking at the source here:
http://sourceforge.net/apps/trac/pyusb/browser/trunk/usb/__init__.py
It looks like the _setup_log() method should really be changed.

If you follow: 
http://docs.python.org/howto/logging.html#configuring-logging-for-a-library  it 
should really just be this...

logger = logging.getLogger("usb")
logging.getLogger('usb').addHandler(logging.NullHandler())
(With the existing implementation of NullHandler for python < 2.7)

The docs then need to be changed of course :)  But, the docs just become, "use 
python logging, pyusb uses the following loggers: "usb" "usb.blah" and "usb.wop"

Cheers,
Karl P

[1] compatible is a bit of a long story for java logging, but it mostly all 
behaves the same, with differences in how you configure them.





>
> Do you have a reference to log4j/slf4j examples that you mention?
> Again, I'd expect to explictly enable the logging in the library I'm
> using if I want to see it.
>
> If we can find precedent for the reverse behavior I can modify my
> expectations, it just doesn't seem right to me ;-)    Beauty is in the
> eye of the beholder and all that :-)
>
> Chris
>
> ------------------------------------------------------------------------------
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to