From c38aace3aef62d2775d4c20639df34eed3df6658 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Mon, 3 Nov 2025 21:35:09 +0100 Subject: [PATCH] Add debug setting for email-sending Fix #86 --- bugsink/conf_templates/docker.py.template | 4 ++++ bugsink/conf_templates/singleserver.py.template | 4 ++++ bugsink/settings/default.py | 7 +++++++ bugsink/utils.py | 2 ++ 4 files changed, 17 insertions(+) diff --git a/bugsink/conf_templates/docker.py.template b/bugsink/conf_templates/docker.py.template index c7959b6..bceb20b 100644 --- a/bugsink/conf_templates/docker.py.template +++ b/bugsink/conf_templates/docker.py.template @@ -115,6 +115,10 @@ if os.getenv("EMAIL_HOST"): # True, we use that. EMAIL_USE_SSL = os.getenv("EMAIL_USE_SSL", "False").lower() in ("true", "1", "yes") EMAIL_USE_TLS = os.getenv("EMAIL_USE_TLS", str(not EMAIL_USE_SSL)).lower() in ("true", "1", "yes") + + if os.getenv("EMAIL_LOGGING", "false").lower() in ("true", "1", "yes"): + LOGGING['loggers']['bugsink.email']['level'] = "INFO" + else: # print("WARNING: EMAIL_HOST not set; email will not be sent") EMAIL_BACKEND = "bugsink.email_backends.QuietConsoleEmailBackend" diff --git a/bugsink/conf_templates/singleserver.py.template b/bugsink/conf_templates/singleserver.py.template index 854a482..06e51c4 100644 --- a/bugsink/conf_templates/singleserver.py.template +++ b/bugsink/conf_templates/singleserver.py.template @@ -71,6 +71,10 @@ EMAIL_BACKEND = "bugsink.email_backends.QuietConsoleEmailBackend" # instead of # EMAIL_USE_TLS = ... # EMAIL_USE_SSL = ... +# Uncomment the line below to show all sent emails in the logs +# LOGGING['loggers']['bugsink.email']['level'] = "INFO" + + SERVER_EMAIL = DEFAULT_FROM_EMAIL = "Bugsink " # constants for "create by" (user/team/project) settings diff --git a/bugsink/settings/default.py b/bugsink/settings/default.py index cc2b469..4591012 100644 --- a/bugsink/settings/default.py +++ b/bugsink/settings/default.py @@ -356,6 +356,13 @@ LOGGING['loggers']['bugsink.performance'] = { "propagate": False, } +# Email logging is hidden below WARNING by default, but this can be changed by setting the level to INFO. +LOGGING['loggers']['bugsink.email'] = { + "level": "WARNING", + "handlers": ["console"], + "propagate": False, +} + # Snappea Logging LOGGING["formatters"]["snappea"] = { "format": "{threadName} - {levelname:7} - {message}", diff --git a/bugsink/utils.py b/bugsink/utils.py index fbe4e57..6df2428 100644 --- a/bugsink/utils.py +++ b/bugsink/utils.py @@ -30,6 +30,8 @@ def send_rendered_email(subject, base_template_name, recipient_list, context=Non ) return + logger.info("Sending email with subject '%s' to %s", subject, recipient_list) + if context is None: context = {}