computed_settings: Move logging callbacks from zerver.lib.logging_util.

This breaks an import cycle that prevented django-stubs from inferring
types for django.conf.settings.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-09-23 21:49:09 -07:00
committed by Tim Abbott
parent 9eefc290a9
commit 7908e2c3a5
2 changed files with 18 additions and 22 deletions

View File

@@ -120,25 +120,6 @@ class RequireReallyDeployed(logging.Filter):
return settings.PRODUCTION
def skip_200_and_304(record: logging.LogRecord) -> bool:
# Apparently, `status_code` is added by Django and is not an actual
# attribute of LogRecord; as a result, mypy throws an error if we
# access the `status_code` attribute directly.
if getattr(record, "status_code", None) in [200, 304]:
return False
return True
def skip_site_packages_logs(record: logging.LogRecord) -> bool:
# This skips the log records that are generated from libraries
# installed in site packages.
# Workaround for https://code.djangoproject.com/ticket/26886
if "site-packages" in record.pathname:
return False
return True
def find_log_caller_module(record: logging.LogRecord) -> Optional[str]:
"""Find the module name corresponding to where this record was logged.