2020-01-03 13:01:31 +00:00
|
|
|
package loopd
|
2019-03-06 20:13:50 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btclog"
|
2020-06-17 20:25:57 +00:00
|
|
|
"github.com/lightninglabs/lndclient"
|
2019-10-28 16:06:07 +00:00
|
|
|
"github.com/lightninglabs/loop"
|
|
|
|
"github.com/lightninglabs/loop/loopdb"
|
2019-12-05 10:19:11 +00:00
|
|
|
"github.com/lightninglabs/loop/lsat"
|
2019-10-28 16:06:07 +00:00
|
|
|
"github.com/lightningnetwork/lnd/build"
|
2019-03-06 20:13:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-10-28 16:06:07 +00:00
|
|
|
logWriter = build.NewRotatingLogWriter()
|
|
|
|
|
|
|
|
log = build.NewSubLogger("LOOPD", logWriter.GenSubLogger)
|
2019-03-06 20:13:50 +00:00
|
|
|
)
|
|
|
|
|
2019-10-28 16:06:07 +00:00
|
|
|
func init() {
|
|
|
|
setSubLogger("LOOPD", log, nil)
|
|
|
|
addSubLogger("LOOP", loop.UseLogger)
|
|
|
|
addSubLogger("LNDC", lndclient.UseLogger)
|
|
|
|
addSubLogger("STORE", loopdb.UseLogger)
|
2019-12-05 10:19:11 +00:00
|
|
|
addSubLogger(lsat.Subsystem, lsat.UseLogger)
|
2019-10-28 16:06:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// addSubLogger is a helper method to conveniently create and register the
|
|
|
|
// logger of a sub system.
|
|
|
|
func addSubLogger(subsystem string, useLogger func(btclog.Logger)) {
|
|
|
|
logger := build.NewSubLogger(subsystem, logWriter.GenSubLogger)
|
|
|
|
setSubLogger(subsystem, logger, useLogger)
|
|
|
|
}
|
|
|
|
|
|
|
|
// setSubLogger is a helper method to conveniently register the logger of a sub
|
|
|
|
// system.
|
|
|
|
func setSubLogger(subsystem string, logger btclog.Logger,
|
|
|
|
useLogger func(btclog.Logger)) {
|
2019-03-06 20:13:50 +00:00
|
|
|
|
2019-10-28 16:06:07 +00:00
|
|
|
logWriter.RegisterSubLogger(subsystem, logger)
|
|
|
|
if useLogger != nil {
|
|
|
|
useLogger(logger)
|
|
|
|
}
|
2019-03-06 20:13:50 +00:00
|
|
|
}
|