Disable logging for a python module in one context but not another
问题 I have some code that uses the requests module to communicate with a logging API. However, requests itself, through urllib3 , does logging. Naturally, I need to disable logging so that requests to the logging API don't cause an infinite loop of logs. So, in the module I do the logging calls in, I do logging.getLogger("requests").setLevel(logging.CRITICAL) to mute routine request logs. However, this code is intended to load and run arbitrary user code. Since the python logging module