From 1d7e382097319b66a4e1716a5c6bc8b7886b1fe7 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Wed, 31 Oct 2018 20:42:07 -0700 Subject: [PATCH] watchtower/lookout/log: adds lookout subsystem logger --- watchtower/lookout/log.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 watchtower/lookout/log.go diff --git a/watchtower/lookout/log.go b/watchtower/lookout/log.go new file mode 100644 index 000000000..b569b4ae0 --- /dev/null +++ b/watchtower/lookout/log.go @@ -0,0 +1,29 @@ +package lookout + +import ( + "github.com/btcsuite/btclog" + "github.com/lightningnetwork/lnd/build" +) + +// log is a logger that is initialized with no output filters. This +// means the package will not perform any logging by default until the caller +// requests it. +var log btclog.Logger + +// The default amount of logging is none. +func init() { + UseLogger(build.NewSubLogger("WTWR", nil)) +} + +// DisableLog disables all library log output. Logging output is disabled +// by default until UseLogger is called. +func DisableLog() { + UseLogger(btclog.Disabled) +} + +// UseLogger uses a specified Logger to output package logging info. +// This should be used in preference to SetLogWriter if the caller is also +// using btclog. +func UseLogger(logger btclog.Logger) { + log = logger +}