From 25b04e79d6748ca846043157988127e714646db3 Mon Sep 17 00:00:00 2001 From: Proudlock <270015376@geaerospace.com> Date: Wed, 9 Sep 2026 09:20:04 -0400 Subject: [PATCH] Add verbose logging to debug operator report email alerts - Log when function is called with report details - Log SMTP config and recipients being used - Log before and after email send attempt - Change warning to error with full traceback for failures --- plugins/endpoints/api/routes.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/endpoints/api/routes.py b/plugins/endpoints/api/routes.py index 3a0e1a57..f407e7d8 100644 --- a/plugins/endpoints/api/routes.py +++ b/plugins/endpoints/api/routes.py @@ -2942,12 +2942,18 @@ def _send_operator_report_alert(report, asset_id, hostname): from flask import url_for, request from shopdb.utils.mailer import get_smtp_config, _normalize_recipients + current_app.logger.info('_send_operator_report_alert called for report %d, asset %d, hostname %s', + report.operatorreportid, asset_id, hostname) + # Check if we have recipients before doing expensive work config = get_smtp_config() + current_app.logger.info('SMTP config: enabled=%s, host=%s, alert_recipients=%s', + config.get('enabled'), config.get('host'), config.get('alert_recipients')) recipients = _normalize_recipients(config['alert_recipients']) if not recipients: - current_app.logger.debug('Skipping operator report alert: no alert recipients configured') + current_app.logger.warning('Skipping operator report alert: no alert recipients configured') return + current_app.logger.info('Will send alert to %d recipient(s): %s', len(recipients), recipients) asset = Asset.query.get(asset_id) if not asset: @@ -3107,10 +3113,12 @@ def upload_operator_report(): db.session.rollback() # Send email alert to default alert recipients + current_app.logger.info('Operator report %d saved, attempting to send email alert', report.operatorreportid) try: _send_operator_report_alert(report, asset_id, hostname) + current_app.logger.info('Email alert function completed for report %d', report.operatorreportid) except Exception as e: - current_app.logger.warning('Failed to send operator report alert email: %s', e) + current_app.logger.error('Failed to send operator report alert email for report %d: %s', report.operatorreportid, e, exc_info=True) return success_response(report.to_dict(), message='Operator report received', http_code=201)