[FIX] 修正下位機 Discord 告警發送條件與層級對等
1. 調整 MachineLog 的 created 監聽器,使 submachine 類型日誌僅在 level 為 warning 或 error 時才派發 Discord 通知任務,避免 info 狀態日誌(如出貨中、平台上升中)洗板告警。 2. 優化 DiscordWebhookService 的下位機異常渲染,根據日誌嚴重程度 (level) 動態調整標題前面的 Emoji 圖示,error 級別顯示 🚨,warning 級別顯示 ⚠️。
This commit is contained in:
parent
dcdfe1382e
commit
acde99e383
@ -58,7 +58,10 @@ class MachineLog extends Model
|
||||
}
|
||||
}
|
||||
} elseif ($log->type === 'submachine') {
|
||||
$shouldNotify = true;
|
||||
// 下位機日誌僅在 warning 或 error 級別時發送 Discord 告警,info 狀態日誌不發送
|
||||
if (in_array($log->level, ['warning', 'error'])) {
|
||||
$shouldNotify = true;
|
||||
}
|
||||
} elseif ($log->level === 'error') {
|
||||
$shouldNotify = true;
|
||||
}
|
||||
|
||||
@ -151,7 +151,8 @@ class DiscordWebhookService
|
||||
$translatedError = __($translatedError);
|
||||
}
|
||||
|
||||
$title = '⚠️ ' . $this->cleanTranslation(__('Submachine Exception'), $companyLocale);
|
||||
$icon = ($log->level === 'error') ? '🚨 ' : '⚠️ ';
|
||||
$title = $icon . $this->cleanTranslation(__('Submachine Exception'), $companyLocale);
|
||||
$description = $this->cleanTranslation(__('Vending machine reported a submachine hardware error.'), $companyLocale);
|
||||
$color = ($log->level === 'error') ? 14753096 : 14251782;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user