fix: "Lazy" Stringers to defer Sprintf and Hash until logs print (#8845)

This commit is contained in:
Joe Abbey
2022-06-23 14:56:34 -04:00
committed by GitHub
parent a3cc3d98b9
commit 4a1df4911d
23 changed files with 226 additions and 115 deletions

View File

@@ -8,6 +8,8 @@ import (
"os"
"os/signal"
"syscall"
"github.com/tendermint/tendermint/libs/log"
)
type logger interface {
@@ -21,7 +23,7 @@ func TrapSignal(logger logger, cb func()) {
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
for sig := range c {
logger.Info(fmt.Sprintf("captured %v, exiting...", sig))
logger.Info("signal trapped", "msg", log.NewLazySprintf("captured %v, exiting...", sig))
if cb != nil {
cb()
}