Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
42 lines
953 B
Go
42 lines
953 B
Go
package log
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
cmtbytes "github.com/cometbft/cometbft/libs/bytes"
|
|
)
|
|
|
|
type LazySprintf struct {
|
|
format string
|
|
args []interface{}
|
|
}
|
|
|
|
// NewLazySprintf defers fmt.Sprintf until the Stringer interface is invoked.
|
|
// This is particularly useful for avoiding calling Sprintf when debugging is not
|
|
// active.
|
|
func NewLazySprintf(format string, args ...interface{}) *LazySprintf {
|
|
return &LazySprintf{format, args}
|
|
}
|
|
|
|
func (l *LazySprintf) String() string {
|
|
return fmt.Sprintf(l.format, l.args...)
|
|
}
|
|
|
|
type LazyBlockHash struct {
|
|
block hashable
|
|
}
|
|
|
|
type hashable interface {
|
|
Hash() cmtbytes.HexBytes
|
|
}
|
|
|
|
// NewLazyBlockHash defers block Hash until the Stringer interface is invoked.
|
|
// This is particularly useful for avoiding calling Sprintf when debugging is not
|
|
// active.
|
|
func NewLazyBlockHash(block hashable) *LazyBlockHash {
|
|
return &LazyBlockHash{block}
|
|
}
|
|
|
|
func (l *LazyBlockHash) String() string {
|
|
return l.block.Hash().String()
|
|
}
|