File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 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+ )
Original file line number Diff line number Diff line change 1+ from setuptools import find_packages , setup
2+
3+ setup (
4+ name = "python-logging-filters" ,
5+ version = "0.1.0" ,
6+ description = (
7+ "Simple filters for standard python logging, e.g. for suppressing "
8+ "noisy 3rd party framework logging."
9+ ),
10+ author = "puzzleYOU GmbH" ,
11+ 12+ url = "https://www.puzzleyou.de/" ,
13+ license = "GPLv3" ,
14+ platforms = ["any" ],
15+ packages = find_packages (),
16+ install_requires = [],
17+ zip_safe = True ,
18+ )
You can’t perform that action at this time.
0 commit comments