Skip to content

Commit 760b60e

Browse files
htlcswitch/hop: add default logger initialization
Without this, running hop tests in isolation panics because the package's log variable is nil until the parent htlcswitch package calls UseLogger during init.
1 parent 1801596 commit 760b60e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

htlcswitch/hop/log.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@ package hop
22

33
import (
44
"github.com/btcsuite/btclog/v2"
5+
"github.com/lightningnetwork/lnd/build"
56
)
67

8+
// Subsystem defines the logging sub system name of this package.
9+
const Subsystem = "HOPS"
10+
711
// log is a logger that is initialized with no output filters. This
812
// means the package will not perform any logging by default until the caller
913
// requests it.
1014
var log btclog.Logger
1115

16+
// The default amount of logging is none.
17+
func init() {
18+
UseLogger(build.NewSubLogger(Subsystem, nil))
19+
}
20+
21+
// DisableLog disables all library log output. Logging output is disabled
22+
// by default until UseLogger is called.
23+
func DisableLog() {
24+
UseLogger(btclog.Disabled)
25+
}
26+
1227
// UseLogger uses a specified Logger to output package logging info. This
1328
// function is called from the parent package htlcswitch logger initialization.
1429
func UseLogger(logger btclog.Logger) {

0 commit comments

Comments
 (0)