0

I am learning about the logging package, and when outputting log control, I find that it is always impossible to output logs at levels below info.As follow:

import logging

logger1 = logging.getLogger("logger1")
print(logger1.isEnabledFor(logging.INFO));

logger1.setLevel(logging.INFO)
print(logger1.isEnabledFor(logging.INFO));

logger1.debug("This is  DEBUG of logger1 !!")
logger1.info("This is  INFO of logger1 !!")
logger1.warning("This is  WARNING of logger1 !!")
logger1.error("This is  ERROR of logger1 !!")
logger1.critical("This is  CRITICAL of logger1 !!")

log as follow

(venv) ➜  cloud_test python3 testcase/test.py
False
True
This is  WARNING of logger1 !!
This is  ERROR of logger1 !!
This is  CRITICAL of logger1 !!

I check the bug level debug,notset,info ,I find that it is always impossible to output logs at levels below info. Is the code has some pro?

Baker
  • 71
  • 5

0 Answers0