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

     1  package channeldb
     2  
     3  import (
     4  	"github.com/decred/dcrlnd/build"
     5  	dcrmigration01 "github.com/decred/dcrlnd/channeldb/dcrmigrations/migration01"
     6  	dcrmigration02 "github.com/decred/dcrlnd/channeldb/dcrmigrations/migration02"
     7  	mig "github.com/decred/dcrlnd/channeldb/migration"
     8  	"github.com/decred/dcrlnd/channeldb/migration12"
     9  	"github.com/decred/dcrlnd/channeldb/migration13"
    10  	"github.com/decred/dcrlnd/channeldb/migration16"
    11  	"github.com/decred/dcrlnd/channeldb/migration20"
    12  	"github.com/decred/dcrlnd/channeldb/migration24"
    13  	"github.com/decred/dcrlnd/channeldb/migration_01_to_11"
    14  	"github.com/decred/dcrlnd/kvdb"
    15  	"github.com/decred/slog"
    16  )
    17  
    18  // log is a logger that is initialized with no output filters.  This
    19  // means the package will not perform any logging by default until the caller
    20  // requests it.
    21  var log slog.Logger
    22  
    23  func init() {
    24  	UseLogger(build.NewSubLogger("CHDB", nil))
    25  }
    26  
    27  // DisableLog disables all library log output.  Logging output is disabled
    28  // by default until UseLogger is called.
    29  func DisableLog() {
    30  	UseLogger(slog.Disabled)
    31  }
    32  
    33  // UseLogger uses a specified Logger to output package logging info.
    34  // This should be used in preference to SetLogWriter if the caller is also
    35  // using slog.
    36  func UseLogger(logger slog.Logger) {
    37  	log = logger
    38  	mig.UseLogger(logger)
    39  	migration_01_to_11.UseLogger(logger)
    40  	migration12.UseLogger(logger)
    41  	migration13.UseLogger(logger)
    42  	migration16.UseLogger(logger)
    43  	migration20.UseLogger(logger)
    44  	migration24.UseLogger(logger)
    45  	kvdb.UseLogger(logger)
    46  
    47  	dcrmigration01.UseLogger(logger)
    48  	dcrmigration02.UseLogger(logger)
    49  }