I am working on a piece of code which instantiates its own logger with its own handlers and format.
Now I've added a use of a library which uses the logging module directly and it screws up my logger - The original logger starts printing each line twice in different formats while the default logger prints nothing at all.
Any suggestions? MCVE:
import sys
import logging
log = logging.getLogger('foo')
log.addHandler(logging.StreamHandler(sys.stdout))
log.setLevel(logging.DEBUG)
log.info("works once")
logging.info("Isn't printed")
log.info("printed twice with different format")
Output:
works once
printed twice with different format
INFO:foo:printed twice with different format
It also doesnt seem like the default logger somehow adds an extra handler to my logger instance:
> print log.handlers
[<logging.StreamHandler object at 0x7f5d14314990>]
I can't change the module I've included...