PEP 391 (Dictionary-Based Configuration for Logging) Updated

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Oct 28 18:12:58 EDT 2009


Wolodja Wentland <wentland <at> cl.uni-heidelberg.de> writes:

> > All feedback gratefully received!
> 
> The PEP does not seem to specify how handler are retrieved by their
> name/id. How should this work? Especially given the statement:
> 
>     "The handler name lookup dictionary is for configuration use only
>      and will not become part of the public API for the package."
> 

What I mean by this is that, if you specify some handlers in the initial
configuration:

handlers:
  console:
    # configuration for a handler
  file:
    # configuration for a handler
  email:
    # configuration for a handler

then internally, there will be a map which has keys "console", "file" and
"email" pointing to the respective handlers. In a later incremental call,
you can do

handlers:
  console:
    level = ...
  file:
    level = ...
  email:
    level = ...

and the levels will be set on the handlers previously set up with the same
ids.

If you set up handlers programmatically and give them names:

h = logging.StreamHandler()

h.name = "console"

this will add an entry to the map with key "console" and a reference to h as
the value.

Regards,

Vinay Sajip




More information about the Python-list mailing list