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

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