diff --git a/src/server/BreCal/__init__.py b/src/server/BreCal/__init__.py index 964f5b9..8d37e1d 100644 --- a/src/server/BreCal/__init__.py +++ b/src/server/BreCal/__init__.py @@ -83,6 +83,8 @@ def create_app(test_config=None, instance_path=None): if app.config.get("SECRET_KEY"): os.environ["SECRET_KEY"] = app.config["SECRET_KEY"] + defs.SMTP_DEBUG_LEVEL = app.config.get("SMTP_DEBUG_LEVEL", defs.SMTP_DEBUG_LEVEL) + local_db.initPool(os.path.dirname(app.instance_path), config=app.config) logging.info('App started') diff --git a/src/server/BreCal/schemas/defs.py b/src/server/BreCal/schemas/defs.py index 019345e..3d92c54 100644 --- a/src/server/BreCal/schemas/defs.py +++ b/src/server/BreCal/schemas/defs.py @@ -18,3 +18,6 @@ shipcall_types = { 3: "Shifting" } +# Email transport logging (0 = quiet, 1 = verbose) +SMTP_DEBUG_LEVEL = 0 + diff --git a/src/server/BreCal/services/schedule_routines.py b/src/server/BreCal/services/schedule_routines.py index 61e36cc..da28be8 100644 --- a/src/server/BreCal/services/schedule_routines.py +++ b/src/server/BreCal/services/schedule_routines.py @@ -142,7 +142,11 @@ def SendEmails(email_dict): conn = smtplib.SMTP_SSL(defs.email_credentials["server"], defs.email_credentials["port"]) else: conn = smtplib.SMTP(defs.email_credentials["server"], defs.email_credentials["port"]) - conn.set_debuglevel(1) # set this to 0 to disable debug output to log + try: + smtp_debug_level = int(defs.SMTP_DEBUG_LEVEL) + except (TypeError, ValueError): + smtp_debug_level = 0 + conn.set_debuglevel(1 if smtp_debug_level else 0) conn.ehlo() if encryption_norm in ("STARTTLS", "STARTSSL"): conn.starttls() @@ -306,6 +310,13 @@ def SendNotifications(): pass # mark as sent + logging.info( + "Notification finalized (level=2): id=%s shipcall_id=%s participant_id=%s type=%s", + notification.id, + notification.shipcall_id, + notification.participant_id, + notification.type, + ) commands.execute("UPDATE notification SET level = 2 WHERE id = ?id?", param={"id":notification.id}) # send emails (if any)