diff --git a/lnwallet/btcwallet/log.go b/lnwallet/btcwallet/log.go new file mode 100644 index 000000000..878db08e6 --- /dev/null +++ b/lnwallet/btcwallet/log.go @@ -0,0 +1,32 @@ +package btcwallet + +import ( + "github.com/btcsuite/btclog" + "github.com/lightningnetwork/lnd/build" +) + +// Subsystem defines the logging code for this subsystem. +const Subsystem = "BTWL" + +// 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)) +} + +// DisableLog disables all library log output. Logging output is disabled by +// default until UseLogger is called. +func DisableLog() { + UseLogger(btclog.Disabled) +} + +// 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 +} diff --git a/lnwallet/log.go b/lnwallet/log.go index 31881e2d1..341edeca7 100644 --- a/lnwallet/log.go +++ b/lnwallet/log.go @@ -5,7 +5,6 @@ import ( "github.com/btcsuite/btcwallet/chain" btcwallet "github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wtxmgr" - "github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/lnwallet/chainfee" ) diff --git a/lnwallet/rpcwallet/log.go b/lnwallet/rpcwallet/log.go new file mode 100644 index 000000000..190aa623a --- /dev/null +++ b/lnwallet/rpcwallet/log.go @@ -0,0 +1,32 @@ +package rpcwallet + +import ( + "github.com/btcsuite/btclog" + "github.com/lightningnetwork/lnd/build" +) + +// Subsystem defines the logging code for this subsystem. +const Subsystem = "RPWL" + +// 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)) +} + +// DisableLog disables all library log output. Logging output is disabled by +// default until UseLogger is called. +func DisableLog() { + UseLogger(btclog.Disabled) +} + +// 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 +} diff --git a/log.go b/log.go index 68b592bb4..be289b6c0 100644 --- a/log.go +++ b/log.go @@ -29,8 +29,10 @@ import ( "github.com/lightningnetwork/lnd/lnrpc/verrpc" "github.com/lightningnetwork/lnd/lnrpc/walletrpc" "github.com/lightningnetwork/lnd/lnwallet" + "github.com/lightningnetwork/lnd/lnwallet/btcwallet" "github.com/lightningnetwork/lnd/lnwallet/chancloser" "github.com/lightningnetwork/lnd/lnwallet/chanfunding" + "github.com/lightningnetwork/lnd/lnwallet/rpcwallet" "github.com/lightningnetwork/lnd/monitoring" "github.com/lightningnetwork/lnd/netann" "github.com/lightningnetwork/lnd/peer" @@ -163,6 +165,8 @@ func SetupLoggers(root *build.RotatingLogWriter, interceptor signal.Interceptor) AddSubLogger(root, cluster.Subsystem, interceptor, cluster.UseLogger) AddSubLogger(root, rpcperms.Subsystem, interceptor, rpcperms.UseLogger) AddSubLogger(root, tor.Subsystem, interceptor, tor.UseLogger) + AddSubLogger(root, btcwallet.Subsystem, interceptor, btcwallet.UseLogger) + AddSubLogger(root, rpcwallet.Subsystem, interceptor, rpcwallet.UseLogger) } // AddSubLogger is a helper method to conveniently create and register the