2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-11 13:11:12 +00:00
loop/loopd/log.go

45 lines
1.2 KiB
Go
Raw Normal View History

package loopd
2019-03-06 20:13:50 +00:00
import (
"github.com/btcsuite/btclog"
"github.com/lightninglabs/lndclient"
2019-10-28 16:06:07 +00:00
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/liquidity"
2019-10-28 16:06:07 +00:00
"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)
addSubLogger(liquidity.Subsystem, liquidity.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
}