mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 02:02:10 +02:00
multi: add SpewLogClosure to avoid code repetition
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package lnutils
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
// 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
|
||||
@@ -15,3 +17,11 @@ func (c LogClosure) String() string {
|
||||
func NewLogClosure(c func() string) LogClosure {
|
||||
return LogClosure(c)
|
||||
}
|
||||
|
||||
// SpewLogClosure takes an interface and returns the string of it created from
|
||||
// `spew.Sdump` in a LogClosure.
|
||||
func SpewLogClosure(a any) LogClosure {
|
||||
return func() string {
|
||||
return spew.Sdump(a)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user