logger.info / logger.error with logger.addHandler - how to split streams?
Alec Taylor
alec.taylor6 at gmail.com
Thu Dec 29 01:24:26 EST 2016
Thanks
On Tue, Dec 27, 2016 at 2:57 AM, gst <g.starck at gmail.com> wrote:
> Le lundi 26 décembre 2016 10:34:48 UTC-5, Alec Taylor a écrit :
> > So I'm putting .info in one StringIO and .error in another StringIO.
> >
> > How do I stop them from both being put into both?
> >
> > Code: http://ideone.com/Nj6Asz
>
>
> Hi,
>
> it's doable with filter on the handlers:
>
>
> def exact_filter(level):
> def filter(record):
> return level == record.levelno
> filter.filter = filter
> return filter
>
> stdout_stream.addFilter(exact_filter(logging.INFO))
> stderr_stream.addFilter(exact_filter(logging.ERROR))
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list