feat(debug): add ShowFlapTolerantEcho flag for enhanced logging control
Build / ubuntu-latest (push) Failing after 3m0s
Build / windows-latest (push) Failing after 3m47s

This commit is contained in:
NanamiAdmin committed 2026-10-12 17:34:55 +08:00
1 parent 03e74f49c3
commit 9137d53286
2 files changed
+19 -10

No files matched your search

+7 -6
View File
@@ -15,12 +15,13 @@ type SystemConfig struct {
// DebugConfig holds debug-level configuration. // DebugConfig holds debug-level configuration.
type DebugConfig struct { type DebugConfig struct {
ShowOneBotMsg bool `json:"showOneBotMsg"` ShowOneBotMsg bool `json:"showOneBotMsg"`
ShowOneBotAction bool `json:"showOneBotAction"` ShowOneBotAction bool `json:"showOneBotAction"`
ShowTelegramMsg bool `json:"showTelegramMsg"` ShowTelegramMsg bool `json:"showTelegramMsg"`
ShowTriggerCmdEcho bool `json:"showTriggerCmdEcho"` ShowTriggerCmdEcho bool `json:"showTriggerCmdEcho"`
ShowKomariTaskEcho bool `json:"showKomariTaskEcho"` ShowKomariTaskEcho bool `json:"showKomariTaskEcho"`
OneBotIgnoreSelfMsg bool `json:"oneBotIgnoreSelfMsg"` OneBotIgnoreSelfMsg bool `json:"oneBotIgnoreSelfMsg"`
ShowFlapTolerantEcho bool `json:"showFlapTolerantEcho"`
} }
// KomariAccount holds Komari login credentials. // KomariAccount holds Komari login credentials.
+12 -4
View File
@@ -372,7 +372,9 @@ func (m *Manager) holdOffline(change node.StatusChange, tolerance time.Duration)
m.flapPending[change.UUID] = held m.flapPending[change.UUID] = held
m.flapMu.Unlock() m.flapMu.Unlock()
postLog.Debug(fmt.Sprintf("Offline for node %s held for %s (flap tolerance)", change.UUID, tolerance)) if config.Current().Debug.ShowFlapTolerantEcho {
postLog.Debug(fmt.Sprintf("Offline for node %s held for %s (flap tolerance)", change.UUID, tolerance))
}
} }
// fireHeldOffline dispatches a held Offline once its window has elapsed. It // fireHeldOffline dispatches a held Offline once its window has elapsed. It
@@ -392,11 +394,15 @@ func (m *Manager) fireHeldOffline(uuid string, held *flapPending) {
// Re-check the allow-list: it may have been edited while the change was // Re-check the allow-list: it may have been edited while the change was
// held, and years-long holds are possible in principle. // held, and years-long holds are possible in principle.
if !config.NodeStatusNotifyEnabled(uuid) { if !config.NodeStatusNotifyEnabled(uuid) {
postLog.Debug(fmt.Sprintf("Held status change for node %s dropped: enableStatusNotify is not enabled", uuid)) if config.Current().Debug.ShowFlapTolerantEcho {
postLog.Debug(fmt.Sprintf("Held status change for node %s dropped: enableStatusNotify is not enabled", uuid))
}
return return
} }
postLog.Info(fmt.Sprintf("Node %s still offline after flap tolerance; reporting it now", uuid)) if config.Current().Debug.ShowFlapTolerantEcho {
postLog.Debug(fmt.Sprintf("Node %s still offline after flap tolerance; reporting it now", uuid))
}
m.dispatchStatusChange(held.change) m.dispatchStatusChange(held.change)
} }
@@ -424,7 +430,9 @@ func (m *Manager) releaseHeldOffline(uuid string) bool {
held.timer.Stop() held.timer.Stop()
delete(m.flapPending, uuid) delete(m.flapPending, uuid)
postLog.Info(fmt.Sprintf("Node %s returned within flap tolerance; suppressed both notifications", uuid)) if config.Current().Debug.ShowFlapTolerantEcho {
postLog.Debug(fmt.Sprintf("Node %s returned within flap tolerance; suppressing both halves", uuid))
}
return true return true
} }