github.com/decred/dcrlnd@v0.7.6/watchtower/log.go (about)

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