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
+11 -2

No files matched your search

+1
View File
@@ -21,6 +21,7 @@ type DebugConfig struct {
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.
+10 -2
View File
@@ -372,8 +372,10 @@ 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()
if config.Current().Debug.ShowFlapTolerantEcho {
postLog.Debug(fmt.Sprintf("Offline for node %s held for %s (flap tolerance)", change.UUID, tolerance)) 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
// claims the entry first and returns without sending if the hold was already // claims the entry first and returns without sending if the hold was already
@@ -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) {
if config.Current().Debug.ShowFlapTolerantEcho {
postLog.Debug(fmt.Sprintf("Held status change for node %s dropped: enableStatusNotify is not enabled", uuid)) 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
} }