Skip to content

Commit

Permalink
Surface Werkzeug and other internal logging to loguru at orig level (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jinnatar authored Jan 7, 2022
1 parent 543c3d7 commit 81375b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mapadroid/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,14 @@ def __init__(self, *args, **kwargs):

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


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

0 comments on commit 81375b5

Please sign in to comment.