Avoid Adding Log Handler To The Root Logger
Closed this issue · 2 comments
HH-MWB commented
Hi, shall we move the log handler from the root logger to the logger created in this module?
The current implementation calls logging.basicConfig
, which will create a handler to root logger. In this approach, other loggers will print to stderr
after importing this library because of the handler in the root logger.
We can simply resolve this issue by creating the handler in the logger instead of calling logging.basicConfig
which adds to the root logger. How do you feel about this?
def _add_handler(logger: logging.Logger) -> None:
handler = logging.StreamHandler()
handler.setFomatter(
logging.Formatter(
fmt="%(asctime)s %(levelname)8s: %(message)s",
datefmt="%m-%d %H:%M:%S",
)
)
logger.addHandler(handler)
_add_handler(logger)
jkklee commented
Of course,thanks for your suggestion. Would you please create a pull request? Tks!
jkklee commented
please try v0.4.3