forked from cerc-io/plugeth
log: remove lazy, remove unused interfaces, unexport methods (#28622)
This change
- Removes interface `log.Format`,
- Removes method `log.FormatFunc`,
- unexports `TerminalHandler.TerminalFormat` formatting methods (renamed to `TerminalHandler.format`)
- removes the notion of `log.Lazy` values
The lazy handler was useful in the old log package, since it
could defer the evaluation of costly attributes until later in the
log pipeline: thus, if the logging was done at 'Trace', we could
skip evaluation if logging only was set to 'Info'.
With the move to slog, this way of deferring evaluation is no longer
needed, since slog introduced 'Enabled': the caller can thus do
the evaluate-or-not decision at the callsite, which is much more
straight-forward than dealing with lazy reflect-based evaluation.
Also, lazy evaluation would not work with 'native' slog, as in, these
two statements would be evaluated differently:
```golang
log.Info("foo", "my lazy", lazyObj)
slog.Info("foo", "my lazy", lazyObj)
```
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package msgrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"math"
|
||||
"sort"
|
||||
@@ -410,7 +411,9 @@ func (t *Trackers) tune() {
|
||||
|
||||
t.tuned = time.Now()
|
||||
t.log.Debug("Recalculated msgrate QoS values", "rtt", t.roundtrip, "confidence", t.confidence, "ttl", t.targetTimeout(), "next", t.tuned.Add(t.roundtrip))
|
||||
t.log.Trace("Debug dump of mean capacities", "caps", log.Lazy{Fn: t.meanCapacities})
|
||||
if t.log.Enabled(context.Background(), log.LevelTrace) {
|
||||
t.log.Trace("Debug dump of mean capacities", "caps", t.meanCapacities())
|
||||
}
|
||||
}
|
||||
|
||||
// detune reduces the tracker's confidence in order to make fresh measurements
|
||||
|
||||
Reference in New Issue
Block a user