/ routing / log.go
log.go
 1  package routing
 2  
 3  import (
 4  	"github.com/btcsuite/btclog/v2"
 5  	"github.com/lightningnetwork/lnd/build"
 6  	"github.com/lightningnetwork/lnd/routing/chainview"
 7  )
 8  
 9  // log is a logger that is initialized with no output filters.  This means the
10  // package will not perform any logging by default until the caller requests
11  // it.
12  var log btclog.Logger
13  
14  const Subsystem = "CRTR"
15  
16  // The default amount of logging is none.
17  func init() {
18  	UseLogger(build.NewSubLogger(Subsystem, nil))
19  }
20  
21  // DisableLog disables all library log output.  Logging output is disabled by
22  // by default until UseLogger is called.
23  func DisableLog() {
24  	UseLogger(btclog.Disabled)
25  }
26  
27  // UseLogger uses a specified Logger to output package logging info.  This
28  // should be used in preference to SetLogWriter if the caller is also using
29  // btclog.
30  func UseLogger(logger btclog.Logger) {
31  	log = logger
32  	chainview.UseLogger(logger)
33  }