Wish: Allow all log Handlers to accept the level argument

Peter Otten __peter__ at web.de
Thu May 24 03:22:49 EDT 2012


Fayaz Yusuf Khan wrote:

> ***TRIVIAL ISSUE***, but this has been irking me for a while now.
> The main logging.Handler class' __init__ accepts a level argument while
> none of its children do. The poor minions seem to be stuck with the
> setLevel method which considerably lengthens the code.
> 
> In short:
> Let's do this:
> root.addHandler(FileHandler('debug.log', level=DEBUG)
> Instead of this:
> debug_file_handler = FileHandler('debug.log')
> debug_file_handler.setLevel(DEBUG)
> root.addHandler(debug_file_handler)
> 
> Python 2.7

Your suggestion comes too late for Python 2 for which only bugfixes are 
accepted. For Python 3.3 you could write a patch and make a feature request 
on http://bugs.python.org/ .




More information about the Python-list mailing list