Antoine Pitrou <solipsis <at> pitrou.net> writes:

> 
> Why wouldn't it be the default for all logging calls ? Such special
> cases don't really make things easy to remember.
>

One size doesn't fit all. Everything's documented reasonably well. If you use it
often, you remember it. If you use it seldom, you might need to look things up.
 

> You seem pretty tied up to the "application developer" situation. There
> are cases (scripts, prototyping, etc.) where you certainly want to see
> error messages (errors should not pass silently) but don't want to
> configure logging for each of the libraries you use.

You don't have to configure each of the libraries you use. The "application
developer" = "The developer who is not writing a library" = "The person writing
a script, prototyping, etc." I don't mean Application with a capital A. I'm just
using it as a convenient label to mean a library user who is not writing a
library themselves.

 
> Having convenient and understandable defaults would go a long way
> towards making logging more usable, IMO.
> 

The defaults are I believe reasonably convenient, or at least not inconvenient:

1. If writing a library, add a NullHandler to the top-level logger of your
library, don't add any other handlers by default (i.e. on import), document the
names of the loggers you use. Otherwise, see the following.

2. If writing a simple script, prototyping etc. i.e. for casual use, use
logging.debug(), logging.info() etc. That's easy enough and convenient enough
for casual users to remember, I hope. All WARNING, ERROR and CRITICAL events in
your code and in that of any libraries you use will be printed to sys.stderr.

3. If slightly less than very casual use (e.g. you want to log to file, or want
a specific message format), call basicConfig(). Just the one extra line to
remember to do, hopefully not too inconvenient. All WARNING, ERROR and CRITICAL
events in your code and in that of any libraries you use will be printed to
sys.stderr, unless you specify a file to log to and/or a different logging
level, in which case what you specified will be used as destination/threshold
for logging messages.

4. For more advanced use, use programmatic configuration, fileConfig or
dictConfig to specify a configuration. Convenience is inversely proportional to
how involved the configuration is.

If you can specify what you think is inconvenient in the above, that would be
helpful.

Regards,

Vinay Sajip

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to