Skip to content

Commit a78b7fa

Browse files
committed
itest: add itest logger
In order for the oracle server harness to have a native way of providing us with logs in the itests we need to set up an itest logger, which is also initiated during test harness setup.
1 parent b37486e commit a78b7fa

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

itest/log.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package itest
2+
3+
import (
4+
"github.com/btcsuite/btclog"
5+
"github.com/lightningnetwork/lnd/build"
6+
)
7+
8+
const Subsystem = "ITST"
9+
10+
// log is a logger that is initialized with no output filters. This means the
11+
// package will not perform any logging by default until the caller requests it.
12+
var log btclog.Logger
13+
14+
// The default amount of logging is none.
15+
func init() {
16+
UseLogger(build.NewSubLogger(Subsystem, nil))
17+
}
18+
19+
// UseLogger uses a specified Logger to output package logging info.
20+
// This should be used in preference to SetLogWriter if the caller is also
21+
// using btclog.
22+
func UseLogger(logger btclog.Logger) {
23+
log = logger
24+
}

itest/test_harness.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/btcsuite/btcd/chaincfg"
1313
"github.com/btcsuite/btcd/chaincfg/chainhash"
1414
"github.com/btcsuite/btcd/rpcclient"
15+
"github.com/btcsuite/btclog"
1516
"github.com/go-errors/errors"
1617
"github.com/lightninglabs/aperture"
1718
"github.com/lightninglabs/lndclient"
@@ -207,7 +208,11 @@ func (h *harnessTest) setupLogging() {
207208
tap.SetupLoggers(h.logWriter, h.interceptor)
208209
aperture.SetupLoggers(h.logWriter, h.interceptor)
209210

210-
h.logWriter.SetLogLevels(*logLevel)
211+
UseLogger(build.NewSubLogger(Subsystem, func(tag string) btclog.Logger {
212+
return h.logWriter.GenSubLogger(tag, func() {})
213+
}))
214+
215+
h.logWriter.SetLogLevels("debug")
211216
}
212217

213218
func (h *harnessTest) newLndClient(

0 commit comments

Comments
 (0)