2019-04-26 17:21:20 -07:00
|
|
|
package wtdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btclog"
|
|
|
|
"github.com/lightningnetwork/lnd/build"
|
2022-10-04 15:49:17 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration1"
|
2022-10-14 10:49:25 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration2"
|
2022-10-15 17:04:29 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration3"
|
2022-12-23 11:14:01 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration4"
|
2023-03-08 10:24:32 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration5"
|
2023-03-09 10:26:06 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration6"
|
2023-03-09 10:30:12 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration7"
|
2023-11-23 15:49:16 +02:00
|
|
|
"github.com/lightningnetwork/lnd/watchtower/wtdb/migration8"
|
2019-04-26 17:21:20 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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("WTDB", 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
|
2022-10-04 15:49:17 +02:00
|
|
|
migration1.UseLogger(logger)
|
2022-10-14 10:49:25 +02:00
|
|
|
migration2.UseLogger(logger)
|
2022-10-15 17:04:29 +02:00
|
|
|
migration3.UseLogger(logger)
|
2022-12-23 11:14:01 +02:00
|
|
|
migration4.UseLogger(logger)
|
2023-03-08 10:24:32 +02:00
|
|
|
migration5.UseLogger(logger)
|
2023-03-09 10:26:06 +02:00
|
|
|
migration6.UseLogger(logger)
|
2023-03-09 10:30:12 +02:00
|
|
|
migration7.UseLogger(logger)
|
2023-11-23 15:49:16 +02:00
|
|
|
migration8.UseLogger(logger)
|
2019-04-26 17:21:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2019-09-10 12:27:39 +02:00
|
|
|
type logClosure func() string // nolint:unused
|
2019-04-26 17:21:20 -07:00
|
|
|
|
|
|
|
// String invokes the underlying function and returns the result.
|
|
|
|
func (c logClosure) String() string {
|
|
|
|
return c()
|
|
|
|
}
|
|
|
|
|
|
|
|
// newLogClosure returns a new closure over a function that returns a string
|
|
|
|
// which itself provides a Stringer interface so that it can be used with the
|
|
|
|
// logging system.
|
2019-09-10 12:27:39 +02:00
|
|
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
2019-04-26 17:21:20 -07:00
|
|
|
return logClosure(c)
|
|
|
|
}
|