Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 81375b5

Browse files
authored
Surface Werkzeug and other internal logging to loguru at orig level (#1220)
- With the previous logic all standard logging logs are downgraded to DEBUG5 regardless of their initial level. This will hide any fatal errors making debugging harder. - Since Werkzeug is quite chatty at INFO level, anything at INFO or above is still downgraded to DEBUG5. This maintains the current behavior for those log messages.
1 parent 543c3d7 commit 81375b5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mapadroid/utils/logging.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,14 @@ def __init__(self, *args, **kwargs):
295295

296296
def emit(self, record):
297297
with logger.contextualize(identifier=self.log_identifier):
298-
logger.opt(depth=6, exception=record.exc_info).log("DEBUG5", record.getMessage())
298+
level = record.levelno
299+
# Downgrade anything INFO and lower to DEBUG5 to match legacy behavior.
300+
# Werkzeug is a bit too chatty at INFO level for it to be useful.
301+
if level <= logging.INFO:
302+
level = "DEBUG5"
303+
else:
304+
level = logging.getLevelName(level)
305+
logger.opt(depth=6, exception=record.exc_info).log(level, record.getMessage())
299306

300307

301308
# this is being used to change log level for gevent/Flask/Werkzeug

0 commit comments

Comments
 (0)