From 48a20adaa3d6a27a46c3c622c5bd5d983da5a3c5 Mon Sep 17 00:00:00 2001 From: xxm Date: Mon, 24 Aug 2026 17:21:34 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20alert=5Flogger.py=E6=A0=B9=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=89=AF=E6=9C=AC=E5=90=8C=E6=AD=A5=E5=88=B0deploy?= =?UTF-8?q?=E6=9D=83=E5=A8=81=E7=89=88(=E7=A1=AC=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E5=BD=92=E4=B8=80=E5=90=8Egit=E5=90=8C=E6=AD=A5,=E9=98=B2deplo?= =?UTF-8?q?y=5Fguard=E5=9B=9E=E6=BB=9A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alert_logger.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/alert_logger.py b/alert_logger.py index 8aa796e9..0eea529b 100644 --- a/alert_logger.py +++ b/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: