I have some pretty long functions which are only used in debugging, but they execute while running in higher loglevels, even though I don't want them to. I understand that I can use if logger.getEffectiveLevel() to bypass this, but is there a "prettier" way to do this?
Example:
import logging
import time
def waitsec():
time.sleep(5)
logger = logging.getLogger("Logger")
logger.setLevel(logging.ERROR)
logger.error(f'Before call waitsec')
logger.debug(f'This is not printed, but still waits 5 seconds {waitsec()}') # I want it to skip
# this completely
logger.error(f'After call waitsec')
Output:
Before call waitsec
After call waitsec