I’m trying to log in python but I’m not seeing logs for anything lower than error. I’ve checked every part of the logging flow, from logger to to appropriate level, handlers, filters at logger and handler level.
I don’t have small reproducible answer since it works as expected when I pare it down, but screenshot and relevant code below, along with PR. What am I missing?
https://docs.python.org/3/howto/logging.html#logging-flow
https://github.com/aivillage/llm_verification/pull/27/files
import logging
class DebugConsoleHandler(logging.Handler):
def emit(self, record):
print(f"Custom Handler: {record.levelname} - {record.msg}")
log.addHandler(DebugConsoleHandler())
log.error("Initialized llm_route in verifications")
log.error(f"Logger name {log.name}")
log.error("Logging Level %s", log.level)
log.setLevel(logging.NOTSET)
log.error("Logging Level %s", log.level)
log.error("Logging Handlers %s", log.handlers)
log.error("Logging filters %s", log.filters)
for handler in log.handlers:
log.error(handler.filters)
# # record = logging.LogRecord("test", level=20, msg="test")
# handler.emit("Test Message")
log.info(
f'Received text generation request from user "{get_current_user().name}" '
f'for challenge ID "{request.json["challenge_id"]}"'
)
log.error(
f'Received text generation request from user "{get_current_user().name}" '
f'for challenge ID "{request.json["challenge_id"]}"'
)
It had to do with the flask app logger setting. I still don’t totally understand how the flask app logging settings affect a logger I’m referencing directly, but at any rate happy to have figured it out
https://github.com/aivillage/llm_verification/pull/27/files#r1382484173
What is
log
in your code?