Skip to content

Commit 0a21311

Browse files
committed
lndservices: create new package for LND-related services
This package will contain services that interact with the LND service. Currently, these services are spread across `lnd_services.go` and other top-level files. As a starting point, this commit adds a new logging subsystem. Subsequent commits will move existing services into this new package.
1 parent c4bb5bc commit 0a21311

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lndservices/log.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package lndservices
2+
3+
import (
4+
"github.com/btcsuite/btclog/v2"
5+
)
6+
7+
// Subsystem defines the logging code for this subsystem.
8+
const Subsystem = "LNDS"
9+
10+
// log is a logger that is initialized with no output filters. This
11+
// means the package will not perform any logging by default until the caller
12+
// requests it.
13+
var log = btclog.Disabled
14+
15+
// DisableLog disables all library log output. Logging output is disabled
16+
// by default until UseLogger is called.
17+
func DisableLog() {
18+
UseLogger(btclog.Disabled)
19+
}
20+
21+
// UseLogger uses a specified Logger to output package logging info.
22+
// This should be used in preference to SetLogWriter if the caller is also
23+
// using btclog.
24+
func UseLogger(logger btclog.Logger) {
25+
log = logger
26+
}

log.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/lightninglabs/taproot-assets/address"
66
"github.com/lightninglabs/taproot-assets/authmailbox"
77
"github.com/lightninglabs/taproot-assets/commitment"
8+
"github.com/lightninglabs/taproot-assets/lndservices"
89
"github.com/lightninglabs/taproot-assets/monitoring"
910
"github.com/lightninglabs/taproot-assets/proof"
1011
"github.com/lightninglabs/taproot-assets/rfq"
@@ -127,6 +128,10 @@ func SetupLoggers(root *build.SubLoggerManager,
127128
AddSubLogger(
128129
root, authmailbox.Subsystem, interceptor, authmailbox.UseLogger,
129130
)
131+
AddSubLogger(
132+
root, lndservices.Subsystem, interceptor,
133+
lndservices.UseLogger,
134+
)
130135
}
131136

132137
// AddSubLogger is a helper method to conveniently create and register the

0 commit comments

Comments
 (0)