error_notify: Remove custom email error reporting handler.

Restore the default django.utils.log.AdminEmailHandler when
ERROR_REPORTING is enabled.  Those with more sophisticated needs can
turn it off and use Sentry or a Sentry-compatible system.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit b285813beb)
This commit is contained in:
Anders Kaseorg
2023-06-09 16:01:05 -07:00
committed by Tim Abbott
parent 290b54a82d
commit a8675741a0
14 changed files with 5 additions and 580 deletions

View File

@@ -693,11 +693,8 @@ if IS_WORKER:
else:
FILE_LOG_PATH = SERVER_LOG_PATH
# This is disabled in a few tests.
LOGGING_ENABLED = True
DEFAULT_ZULIP_HANDLERS = [
*(["zulip_admins"] if ERROR_REPORTING else []),
*(["mail_admins"] if ERROR_REPORTING else []),
"console",
"file",
"errors_file",
@@ -745,9 +742,6 @@ LOGGING: Dict[str, Any] = {
"nop": {
"()": "zerver.lib.logging_util.ReturnTrue",
},
"require_logging_enabled": {
"()": "zerver.lib.logging_util.ReturnEnabled",
},
"require_really_deployed": {
"()": "zerver.lib.logging_util.RequireReallyDeployed",
},
@@ -761,15 +755,14 @@ LOGGING: Dict[str, Any] = {
},
},
"handlers": {
"zulip_admins": {
"mail_admins": {
"level": "ERROR",
"class": "zerver.logging_handlers.AdminNotifyHandler",
"class": "django.utils.log.AdminEmailHandler",
"filters": (
["ZulipLimiter", "require_debug_false", "require_really_deployed"]
if not DEBUG_ERROR_REPORTING
else []
),
"formatter": "default",
},
"auth_file": {
"level": "DEBUG",
@@ -857,7 +850,6 @@ LOGGING: Dict[str, Any] = {
# root logger
"": {
"level": "INFO",
"filters": ["require_logging_enabled"],
"handlers": DEFAULT_ZULIP_HANDLERS,
},
# Django, alphabetized
@@ -968,12 +960,6 @@ LOGGING: Dict[str, Any] = {
"handlers": ["file", "errors_file"],
"propagate": False,
},
# This logger is used only for automated tests validating the
# error-handling behavior of the zulip_admins handler.
"zulip.test_zulip_admins_handler": {
"handlers": ["zulip_admins"],
"propagate": False,
},
"zulip.zerver.webhooks": {
"level": "DEBUG",
"handlers": ["file", "errors_file", "webhook_file"],

View File

@@ -120,13 +120,6 @@ if not PUPPETEER_TESTS:
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
}
# This logger is used only for automated tests validating the
# error-handling behavior of the zulip_admins handler.
LOGGING["loggers"]["zulip.test_zulip_admins_handler"] = {
"handlers": ["zulip_admins"],
"propagate": False,
}
# Here we set various loggers to be less noisy for unit tests.
def set_loglevel(logger_name: str, level: str) -> None:
LOGGING["loggers"].setdefault(logger_name, {})["level"] = level