We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 965b6eb commit 969bc89Copy full SHA for 969bc89
python_logging_filters/__init__.py
@@ -0,0 +1,18 @@
1
+import logging
2
+import re
3
+
4
5
+class DjangoHttp404LogFilter(logging.Filter):
6
+ """Suppresses Django's default 'Not Found: ...' log messages.
7
8
+ See the Django docs how to attach filters to logging handlers via
9
+ the LOGGING setting.
10
+ """
11
+ PATTERN = re.compile("^Not Found:")
12
13
+ def filter(self, record: logging.LogRecord) -> bool:
14
+ return (
15
+ self.PATTERN.fullmatch(record.msg) is not None
16
+ and record.levelno == logging.WARNING
17
+ and record.name.startswith("django")
18
+ )
0 commit comments