integration: print logs to console

This commit is contained in:
yyforyongyu 2023-12-05 16:26:18 +08:00
parent c104e72151
commit 8817ebdd39
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868

26
integration/log.go Normal file
View File

@ -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)
}