Rob Wolfe wrote:
samwyse <[EMAIL PROTECTED]> writes:

The only way that I can see for all three statements to be consistent
is that the root logger starts with an empty list of handlers, and
doesn't instantiate a default handler until either
logging.basicConfig() is called,

That is correct.

or the first time that a message is
logged.

That is not correct. The list of handlers is empty until `basicConfig`
or explicit `addHandler` is called.

This would also seem to imply that there's no way to use an
empty handler list (say, if you want to suppress all logging), because
the root handler will instantiate a handler for you.  Is this correct?

No. Consider this:

import logging
logging.root.warning('error message')
No handlers could be found for logger "root"
logging.root.warning('error message')

Note only one warning message.

Ah, right. It is the module-level functions logging.warn(), etc. that invoke basicConfig() if no handler is present.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to