mirror of https://github.com/vacp2p/nim-libp2p.git
Only log multiple missed heartbeats as info (#763)
This commit is contained in:
parent
d8a9e93ff7
commit
ef594e1e02
|
@ -25,6 +25,14 @@ template heartbeat*(name: string, interval: Duration, body: untyped): untyped =
|
||||||
nextHeartbeat += interval
|
nextHeartbeat += interval
|
||||||
let now = Moment.now()
|
let now = Moment.now()
|
||||||
if nextHeartbeat < now:
|
if nextHeartbeat < now:
|
||||||
info "Missed heartbeat", heartbeat = name, delay = now - nextHeartbeat
|
let
|
||||||
nextHeartbeat = now + interval
|
delay = now - nextHeartbeat
|
||||||
|
itv = interval
|
||||||
|
if delay > itv:
|
||||||
|
info "Missed multiple heartbeats", heartbeat = name,
|
||||||
|
delay = delay, hinterval = itv
|
||||||
|
else:
|
||||||
|
debug "Missed heartbeat", heartbeat = name,
|
||||||
|
delay = delay, hinterval = itv
|
||||||
|
nextHeartbeat = now + itv
|
||||||
await sleepAsync(nextHeartbeat - now)
|
await sleepAsync(nextHeartbeat - now)
|
||||||
|
|
Loading…
Reference in New Issue