Skip to content

Commit

Permalink
dataset: add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
carlaKC committed Jan 31, 2020
1 parent b10d1b9 commit 7398753
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions dataset/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dataset

import (
"github.com/btcsuite/btclog"
"github.com/lightningnetwork/lnd/build"
)

// Subsystem defines the logging code for this subsystem.
const Subsystem = "DSET"

// 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))
}

// 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
}
2 changes: 2 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package terminator

import (
"github.com/btcsuite/btclog"
"github.com/lightninglabs/terminator/dataset"
"github.com/lightninglabs/terminator/recommend"
"github.com/lightningnetwork/lnd/build"
)
Expand All @@ -22,6 +23,7 @@ var (
func init() {
setSubLogger(Subsystem, log, nil)
addSubLogger(recommend.Subsystem, recommend.UseLogger)
addSubLogger(dataset.Subsystem, dataset.UseLogger)
}

// UseLogger uses a specified Logger to output package logging info.
Expand Down

0 comments on commit 7398753

Please sign in to comment.