[Python-ideas] add a LogReader to the logging module
Agustín Herranz Cecilia
agustin.herranz at gmail.com
Thu May 11 13:44:55 EDT 2017
>
> BasicConfig does not allow different settings for different log
> readers, as I can see. E.g.
>
> import logging
> logging.basicConfig(
> level=logging.DEBUG,
> )
> log1 = logging.getLogger("TEST1")
>
> logging.basicConfig(
> level=logging.INFO,
> )
> log2 = logging.getLogger("TEST2")
>
> Here log2 will write out logs at the same level as log1, so
> basicConfic is IMO too basic for a lot of use cases and so you'll have
> to go through the other more verbose setup.
>
> So, this getLogReader function would be more general than basicConfig,
> but also much more useful. (But please educate me, if I've
> misunderstood basicConfig)
The basicConfig sets the root (or "") logger, any messages from other
loggers will end in the root logger if the propagation setting is enabled.
There is the misconception that with the logging module you could have
completely different loggers. In reality there is only 'one' logger, but
with the hierarchy of names and some logic you could use as if there is
more than one logger.
Also in your propose the name of getLoggerReader is misleading as this
implies that there is something to read, there is not, a log event is
something to process, write if you wish (this is the purpose of handlers).
Regards!
More information about the Python-ideas
mailing list