mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
log: unified static address logger
This commit is contained in:
parent
b5b857a198
commit
9e56be74c5
6 changed files with 57 additions and 25 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/lightninglabs/loop/liquidity"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/notifications"
|
||||
"github.com/lightninglabs/loop/staticaddr"
|
||||
"github.com/lightninglabs/loop/sweep"
|
||||
"github.com/lightninglabs/loop/sweepbatcher"
|
||||
"github.com/lightningnetwork/lnd"
|
||||
|
|
@ -38,6 +39,9 @@ func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
|
|||
lnd.AddSubLogger(root, "LNDC", intercept, lndclient.UseLogger)
|
||||
lnd.AddSubLogger(root, "STORE", intercept, loopdb.UseLogger)
|
||||
lnd.AddSubLogger(root, l402.Subsystem, intercept, l402.UseLogger)
|
||||
lnd.AddSubLogger(
|
||||
root, staticaddr.Subsystem, intercept, staticaddr.UseLogger,
|
||||
)
|
||||
lnd.AddSubLogger(
|
||||
root, liquidity.Subsystem, intercept, liquidity.UseLogger,
|
||||
)
|
||||
|
|
@ -57,7 +61,7 @@ func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
|
|||
}
|
||||
|
||||
// genSubLogger creates a logger for a subsystem. We provide an instance of
|
||||
// a signal.Interceptor to be able to shutdown in the case of a critical error.
|
||||
// a signal.Interceptor to be able to shut down in the case of a critical error.
|
||||
func genSubLogger(root *build.RotatingLogWriter,
|
||||
interceptor signal.Interceptor) func(string) btclog.Logger {
|
||||
|
||||
|
|
|
|||
24
staticaddr/address/log.go
Normal file
24
staticaddr/address/log.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package address
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
// Subsystem defines the sub system name of this package.
|
||||
const Subsystem = "SADDR"
|
||||
|
||||
// log is a logger that is initialized with no output filters. This means the
|
||||
// package will not perform any logging by default until the caller requests it.
|
||||
var log btclog.Logger
|
||||
|
||||
// The default amount of logging is none.
|
||||
func init() {
|
||||
UseLogger(build.NewSubLogger(Subsystem, nil))
|
||||
}
|
||||
|
||||
// UseLogger uses a specified Logger to output package logging info. This should
|
||||
// be used in preference to SetLogWriter if the caller is also using btclog.
|
||||
func UseLogger(logger btclog.Logger) {
|
||||
log = logger
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop/staticaddr"
|
||||
"github.com/lightninglabs/loop/staticaddr/script"
|
||||
|
|
@ -22,14 +21,6 @@ import (
|
|||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
)
|
||||
|
||||
var (
|
||||
log btclog.Logger
|
||||
)
|
||||
|
||||
func init() {
|
||||
log = staticaddr.GetLogger()
|
||||
}
|
||||
|
||||
// ManagerConfig holds the configuration for the address manager.
|
||||
type ManagerConfig struct {
|
||||
// AddressClient is the client that communicates with the loop server
|
||||
|
|
|
|||
24
staticaddr/deposit/log.go
Normal file
24
staticaddr/deposit/log.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package deposit
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
// Subsystem defines the sub system name of this package.
|
||||
const Subsystem = "SADDR"
|
||||
|
||||
// log is a logger that is initialized with no output filters. This means the
|
||||
// package will not perform any logging by default until the caller requests it.
|
||||
var log btclog.Logger
|
||||
|
||||
// The default amount of logging is none.
|
||||
func init() {
|
||||
UseLogger(build.NewSubLogger(Subsystem, nil))
|
||||
}
|
||||
|
||||
// UseLogger uses a specified Logger to output package logging info. This should
|
||||
// be used in preference to SetLogWriter if the caller is also using btclog.
|
||||
func UseLogger(logger btclog.Logger) {
|
||||
log = logger
|
||||
}
|
||||
|
|
@ -9,10 +9,8 @@ import (
|
|||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/staticaddr"
|
||||
staticaddressrpc "github.com/lightninglabs/loop/swapserverrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
|
|
@ -33,14 +31,6 @@ const (
|
|||
MaxConfs = 0
|
||||
)
|
||||
|
||||
var (
|
||||
log btclog.Logger
|
||||
)
|
||||
|
||||
func init() {
|
||||
log = staticaddr.GetLogger()
|
||||
}
|
||||
|
||||
// ManagerConfig holds the configuration for the address manager.
|
||||
type ManagerConfig struct {
|
||||
// AddressClient is the client that communicates with the loop server
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package staticaddr
|
|||
|
||||
import (
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/lightninglabs/loop/staticaddr/address"
|
||||
"github.com/lightninglabs/loop/staticaddr/deposit"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
)
|
||||
|
||||
|
|
@ -21,9 +23,6 @@ func init() {
|
|||
// be used in preference to SetLogWriter if the caller is also using btclog.
|
||||
func UseLogger(logger btclog.Logger) {
|
||||
log = logger
|
||||
}
|
||||
|
||||
// GetLogger returns the logger for this package.
|
||||
func GetLogger() btclog.Logger {
|
||||
return log
|
||||
address.UseLogger(log)
|
||||
deposit.UseLogger(log)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue