mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 08:02:25 +02:00
multi: add NewLogClosure
in lnutils
to avoid repetition
And replaces all usage of `logClosure` with `lnutils.LogClosure`.
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil/bech32"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/autopilot"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/tor"
|
||||
"github.com/miekg/dns"
|
||||
@@ -431,7 +432,7 @@ search:
|
||||
}
|
||||
|
||||
log.Tracef("Retrieved SRV records from dns seed: %v",
|
||||
newLogClosure(func() string {
|
||||
lnutils.NewLogClosure(func() string {
|
||||
return spew.Sdump(addrs)
|
||||
}),
|
||||
)
|
||||
|
@@ -27,19 +27,3 @@ func DisableLog() {
|
||||
func UseLogger(logger btclog.Logger) {
|
||||
log = logger
|
||||
}
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations
|
||||
// so don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
return c()
|
||||
}
|
||||
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
return logClosure(c)
|
||||
}
|
||||
|
Reference in New Issue
Block a user