I have found an answer to my original question, within the logging package. I am still looking at the filter option.
Staying inline with my OP I want to easily, temporally, eliminate the logging "clutter" from module fan (assume the fan is not related to what we are currently working on.)
The following line of code can be added to in the main file, TT3.py, after line 15, the basic logger configuration. The line could also be added to the fan module.
A related solution is to include a line like the following. Again it can be put in the main file after the basic configuration.
In my current project code is divided into ~10 modules/classes with 2 custom libraries. Each module is at a different level of completion with some details stubbed out so all the interfaces work, but without some functionality.
With versions of the two lines above I can limit logging to the area I am currently working on without removing and later replacing monitoring lines in other modules. That remove-and-replace scenario is what I wanted to avoid by switching from 'print' to logging.
Placing all the .propagate and .level lines in the main file keeps all the controls in one place.
Staying inline with my OP I want to easily, temporally, eliminate the logging "clutter" from module fan (assume the fan is not related to what we are currently working on.)
The following line of code can be added to in the main file, TT3.py, after line 15, the basic logger configuration. The line could also be added to the fan module.
logging.getLogger("fan").propagate = FalseThis line will stop the "propagation" of log records from module/logger "fan" up to its parent logger, in this case "root". Setting propagate to True (the default) will again include all level appropriate log lines in the output.
A related solution is to include a line like the following. Again it can be put in the main file after the basic configuration.
logging.getLogger("fan").level = logging.WARNINGThis changes the logging level for the named logger only so the debug and info lines from "fan" are blocked but warning and higher lines are included. They may be informative.
In my current project code is divided into ~10 modules/classes with 2 custom libraries. Each module is at a different level of completion with some details stubbed out so all the interfaces work, but without some functionality.
With versions of the two lines above I can limit logging to the area I am currently working on without removing and later replacing monitoring lines in other modules. That remove-and-replace scenario is what I wanted to avoid by switching from 'print' to logging.
Placing all the .propagate and .level lines in the main file keeps all the controls in one place.
Say what you will about Sisyphus. He always has work.