aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-08-26 16:39:06 +0200
committerGravatar Johannes Christ <[email protected]>2019-08-26 16:39:06 +0200
commitb5e70f85eae4b0a5a168af3d37177114677ca641 (patch)
tree0686ba1c58c07ee7c149895cc5821c7fed797a51
parentMerge pull request #397 from python-discord/django-role-api-changes (diff)
Do not send log messages below DEBUG to the site.
-rw-r--r--bot/api.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/bot/api.py b/bot/api.py
index 6ac7ddb95..cd19896e1 100644
--- a/bot/api.py
+++ b/bot/api.py
@@ -101,12 +101,20 @@ class APILoggingHandler(logging.StreamHandler):
)
def emit(self, record: logging.LogRecord):
- # Ignore logging messages which are sent by this logging handler
- # itself. This is required because if we were to not ignore
- # messages emitted by this handler, we would infinitely recurse
- # back down into this logging handler, making the reactor run
- # like crazy, and eventually OOM something. Let's not do that...
- if not record.__dict__.get('via_handler'):
+ # Two checks are performed here:
+ if (
+ # 1. Do not log anything below `DEBUG`. This is only applicable
+ # for the monkeypatched `TRACE` logging level, which has a
+ # lower numeric value than `DEBUG`.
+ record.levelno > logging.DEBUG
+ # 2. Ignore logging messages which are sent by this logging
+ # handler itself. This is required because if we were to
+ # not ignore messages emitted by this handler, we would
+ # infinitely recurse back down into this logging handler,
+ # making the reactor run like crazy, and eventually OOM
+ # something. Let's not do that...
+ and not record.__dict__.get('via_handler')
+ ):
payload = {
'application': 'bot',
'logger_name': record.name,