Good morning/afternoon/evening/time pyRevit team,
First off, a million thanks for pyRevit. What a product.
So my question is about the pyRevit logger (in defence of the topic title the guideline said make it interesting!). I have created my own logger object that I’m looking to use. It’s nothing remarkable, it just has different log levels for the file and console handlers.
However when I “from pyrevit import script” it overrides whatever logger I intend to use downstream of that line. My understanding is that the first logger or logging.config (both ootb python) that is imported and set the minimum log levels for any subsequent loggers used. As such I have tried:
- Importing logging (ootb python) and setting levels to DEBUG. Then importing pyrevit.script
import logging
logging.basicConfig(level=logging.DEBUG)
from pyrevit import script
- Importing pyrevit.script getting the logger using script.get_logger() and then removing the handlers, resetting the handler levels
import logging
from pyrevit import script
logger = script.get_logger()
for h in logger.handlers:
if isinstance(h, logging.fileHandler):
h.setLevel(logging.DEBUG)
- Importing logging (ootb python), getting the root logger and resetting the levels
import logging
logging.get_logger().root.setLevel(logging.DEBUG)
- Importing pyrevit.script, getting the logger using script.get_logger() and then set_verbose_mode() but that makes the console and file handlers the same level, adding too much noise to the output window for everyday users
As you can probably tell by now I’m not suuuuper experienced with the python logging module but I’ve done some stack overflowing and chatgpting but all of the solutions provided have not worked
So my question is: is there a solution for inhibiting pyRevit’s logger dictating the levels for subsequent loggers?
Thank you again for pyRevit and thanks for reading this far if you did!
Cheers, Pete