Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
computed_settings: Move logging callbacks from zerver.lib.logging_util.
Anders Kaseorg7908e2c3a501
diff --git a/zerver/lib/logging_util.py b/zerver/lib/logging_util.pyindex dc902ea8408..b796ed67349 100644--- a/zerver/lib/logging_util.py+++ b/zerver/lib/logging_util.py@@ -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.diff --git a/zproject/computed_settings.py b/zproject/computed_settings.pyindex b11926ff2ac..711e0f907bd 100644--- a/zproject/computed_settings.py+++ b/zproject/computed_settings.py@@ -1,3 +1,4 @@+import loggingimport osimport sysimport time@@ -5,7 +6,6 @@ from copy import deepcopyfrom typing import Any, Dict, List, Tuple, Unionfrom urllib.parse import urljoin-import zerver.lib.logging_utilfrom scripts.lib.zulip_tools import get_tornado_portsfrom zerver.lib.db import TimeTrackingConnection, TimeTrackingCursor@@ -735,6 +735,21 @@ DEFAULT_ZULIP_HANDLERS = ["errors_file",]++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.+ return getattr(record, "status_code", None) not in [200, 304]+++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+ return "site-packages" not in record.pathname++LOGGING: Dict[str, Any] = {"version": 1,"disable_existing_loggers": False,@@ -770,11 +785,11 @@ LOGGING: Dict[str, Any] = {},"skip_200_and_304": {"()": "django.utils.log.CallbackFilter",- "callback": zerver.lib.logging_util.skip_200_and_304,+ "callback": skip_200_and_304,},"skip_site_packages_logs": {"()": "django.utils.log.CallbackFilter",- "callback": zerver.lib.logging_util.skip_site_packages_logs,+ "callback": skip_site_packages_logs,},},"handlers": {