From 6efcdf75e00070e705bef08ec79cda7d835cf007 Mon Sep 17 00:00:00 2001 From: xxm Date: Sat, 22 Aug 2026 10:09:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(alert=5Flogger):=20record=5Falert=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=86=99broadcast=5Fmessages(=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=BA=90,=E5=BC=82=E5=B8=B8=3Dsystem=5Ferror?= =?UTF-8?q?=E7=B1=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/alert_logger.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/deploy/profile-scripts/alert_logger.py b/deploy/profile-scripts/alert_logger.py index 8aa796e9..0eea529b 100644 --- a/deploy/profile-scripts/alert_logger.py +++ b/deploy/profile-scripts/alert_logger.py @@ -68,6 +68,23 @@ def record_alert(level="error", source="", title="", detail="", code="", clear_a except Exception: pass + # 2.5 写入 broadcast_messages 表(统一消息源,异常=system_error类) + try: + from messenger import _classify, DB + import sqlite3 as _sq3 + _cat = _classify(title, detail) + # 异常/告警统一归为 system_error 类(供右上角异常浮窗筛选) + if level in ("error", "critical", "warning"): + _cat = "system_error" + _conn = _sq3.connect(DB, timeout=30) + _conn.execute( + "INSERT INTO broadcast_messages (ts, category, title, content, source) VALUES (?,?,?,?,?)", + (ts_str, _cat, title, detail, source)) + _conn.commit() + _conn.close() + except Exception: + pass + # 3. XMPP 告警(非 info 级别才发,避免轰炸)→ 本地 XMPP 发送服务 :5805 if level != "info": try: