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

43 lines
1.1 KiB
Go

package loopd
import (
"github.com/btcsuite/btclog"
"github.com/lightninglabs/lndclient"
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/loopdb"
"github.com/lightninglabs/loop/lsat"
"github.com/lightningnetwork/lnd/build"
)
var (
logWriter = build.NewRotatingLogWriter()
log = build.NewSubLogger("LOOPD", logWriter.GenSubLogger)
)
func init() {
setSubLogger("LOOPD", log, nil)
addSubLogger("LOOP", loop.UseLogger)
addSubLogger("LNDC", lndclient.UseLogger)
addSubLogger("STORE", loopdb.UseLogger)
addSubLogger(lsat.Subsystem, lsat.UseLogger)
}
// 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)) {
logWriter.RegisterSubLogger(subsystem, logger)
if useLogger != nil {
useLogger(logger)
}
}