From b4326cf59f8de636534c7ae11f6fcfe333e42054 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 5 Dec 2023 16:26:18 +0800 Subject: [PATCH] integration: print logs to console --- integration/log.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 integration/log.go diff --git a/integration/log.go b/integration/log.go new file mode 100644 index 00000000000..26d62174546 --- /dev/null +++ b/integration/log.go @@ -0,0 +1,26 @@ +//go:build rpctest +// +build rpctest + +package integration + +import ( + "os" + + "github.com/btcsuite/btcd/rpcclient" + "github.com/btcsuite/btclog" +) + +type logWriter struct{} + +func (logWriter) Write(p []byte) (n int, err error) { + os.Stdout.Write(p) + return len(p), nil +} + +func init() { + backendLog := btclog.NewBackend(logWriter{}) + testLog := backendLog.Logger("ITEST") + testLog.SetLevel(btclog.LevelDebug) + + rpcclient.UseLogger(testLog) +}