log.go 1.5 KB

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