Skip to content

Avoid using logging.basicConfig in the Manager constructor to allow downstream applications to control their logs appropriately

Nico Madysa requested to merge (removed):issue-7 into master

Closes #7 (closed).

I'm still a bit up in the air about this solution. In theory, it could lead to strange behavior if a Manager is created before basicConfig is called. In theory, this would lead to two handlers being called for each message on this logger. This situation is easy to get into when following PJLSA's advice:

# launcher.py
import pjlsa
with pjlsa.LSAClient().java_api():
    from main_module import main
    main()

# main_module.py
import logging
def main():
    logging.basicConfig()

At the same time, it's difficult to actually observe this, because Manager produces so few log messages, so it is probably fine.

A solution to this might be to set propagate=false on Manager.log and create our own handler unconditionally. This brings its own set of problems though, as users lose the ability to customize Manager.log if they do call basicConfig() beforehand.

Edited by Philip Elson

Merge request reports