Skip to content

Commit ae32c29

Browse files
authored
Merge pull request #9295 from ellemouton/logPerformanceFix
go.mod: bump btclog dep
2 parents c8cfa59 + c2923e2 commit ae32c29

13 files changed

Lines changed: 33 additions & 198 deletions

File tree

build/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ func DefaultLogConfig() *LogConfig {
6767
// config struct translates to.
6868
func (cfg *LoggerConfig) HandlerOptions() []btclog.HandlerOption {
6969
opts := []btclog.HandlerOption{
70-
// The default skip depth used by the logging library is 6 but
71-
// since we wrap the logging handlers with another level of
72-
// abstraction with the handlerSet, we increase the skip depth
73-
// to 7 here.
74-
btclog.WithCallSiteSkipDepth(7),
70+
// We wrap the logger provided by the logging library with
71+
// another layer of abstraction with the handlerSet, and so we
72+
// need to increase the default skip depth by 1.
73+
btclog.WithCallSiteSkipDepth(btclog.DefaultSkipDepth + 1),
7574
}
7675

7776
if cfg.NoTimestamps {

build/handler_sets.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ func (h *handlerSet) Level() btclogv1.Level {
108108
return h.level
109109
}
110110

111+
// WithPrefix returns a copy of the Handler but with the given string prefixed
112+
// to each log message.
113+
//
114+
// NOTE: this is part of the btclog.Handler interface.
115+
func (h *handlerSet) WithPrefix(prefix string) btclog.Handler {
116+
newSet := &handlerSet{set: make([]btclog.Handler, len(h.set))}
117+
for i, handler := range h.set {
118+
newSet.set[i] = handler.WithPrefix(prefix)
119+
}
120+
121+
return newSet
122+
}
123+
111124
// A compile-time check to ensure that handlerSet implements btclog.Handler.
112125
var _ btclog.Handler = (*handlerSet)(nil)
113126

build/prefix_log.go

Lines changed: 0 additions & 167 deletions
This file was deleted.

contractcourt/contract_resolver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/btcsuite/btcd/wire"
1010
"github.com/btcsuite/btclog/v2"
11-
"github.com/lightningnetwork/lnd/build"
1211
"github.com/lightningnetwork/lnd/channeldb"
1312
"github.com/lightningnetwork/lnd/fn"
1413
)
@@ -123,7 +122,7 @@ func newContractResolverKit(cfg ResolverConfig) *contractResolverKit {
123122
// initLogger initializes the resolver-specific logger.
124123
func (r *contractResolverKit) initLogger(resolver ContractResolver) {
125124
logPrefix := fmt.Sprintf("%T(%v):", resolver, r.ChanPoint)
126-
r.log = build.NewPrefixLog(logPrefix, log)
125+
r.log = log.WithPrefix(logPrefix)
127126
}
128127

129128
var (

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/btcsuite/btcd/btcutil/psbt v1.1.8
1111
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
1212
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c
13-
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7
13+
github.com/btcsuite/btclog/v2 v2.0.0
1414
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa
1515
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5
1616
github.com/btcsuite/btcwallet/wallet/txrules v1.2.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtyd
9292
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
9393
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c h1:4HxD1lBUGUddhzgaNgrCPsFWd7cGYNpeFUgd9ZIgyM0=
9494
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhwT3lmrS4H3b/D1XAXxvh+tbhUm8xeHN2y3TQ=
95-
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc=
96-
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
95+
github.com/btcsuite/btclog/v2 v2.0.0 h1:ZfOBItEeLWfU0voi88K72j8vtxP4/dHhxRFf2bxZkVo=
96+
github.com/btcsuite/btclog/v2 v2.0.0/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
9797
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
9898
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa h1:x7vYpwkPL5zeJEWPPaRunybH9ERRMGWeNf7x/0aU/38=
9999
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU=

htlcswitch/link.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/btcsuite/btcd/btcutil"
1515
"github.com/btcsuite/btcd/wire"
1616
"github.com/btcsuite/btclog/v2"
17-
"github.com/lightningnetwork/lnd/build"
1817
"github.com/lightningnetwork/lnd/channeldb"
1918
"github.com/lightningnetwork/lnd/channeldb/models"
2019
"github.com/lightningnetwork/lnd/contractcourt"
@@ -508,7 +507,7 @@ func NewChannelLink(cfg ChannelLinkConfig,
508507
channel: channel,
509508
hodlMap: make(map[models.CircuitKey]hodlHtlc),
510509
hodlQueue: queue.NewConcurrentQueue(10),
511-
log: build.NewPrefixLog(logPrefix, log),
510+
log: log.WithPrefix(logPrefix),
512511
flushHooks: newHookMap(),
513512
outgoingCommitHooks: newHookMap(),
514513
incomingCommitHooks: newHookMap(),

htlcswitch/quiescer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/btcsuite/btclog/v2"
9-
"github.com/lightningnetwork/lnd/build"
109
"github.com/lightningnetwork/lnd/fn"
1110
"github.com/lightningnetwork/lnd/lntypes"
1211
"github.com/lightningnetwork/lnd/lnwire"
@@ -178,7 +177,7 @@ func NewQuiescer(cfg QuiescerCfg) Quiescer {
178177

179178
return &QuiescerLive{
180179
cfg: cfg,
181-
log: build.NewPrefixLog(logPrefix, log),
180+
log: log.WithPrefix(logPrefix),
182181
}
183182
}
184183

lnwallet/channel.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/btcsuite/btcd/wire"
2424
"github.com/btcsuite/btclog/v2"
2525
"github.com/davecgh/go-spew/spew"
26-
"github.com/lightningnetwork/lnd/build"
2726
"github.com/lightningnetwork/lnd/chainntnfs"
2827
"github.com/lightningnetwork/lnd/channeldb"
2928
"github.com/lightningnetwork/lnd/channeldb/models"
@@ -955,7 +954,7 @@ func NewLightningChannel(signer input.Signer,
955954
updateLogs: updateLogs,
956955
Capacity: state.Capacity,
957956
taprootNonceProducer: taprootNonceProducer,
958-
log: build.NewPrefixLog(logPrefix, walletLog),
957+
log: walletLog.WithPrefix(logPrefix),
959958
opts: opts,
960959
}
961960

peer/brontide.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/btcsuite/btclog/v2"
2121
"github.com/davecgh/go-spew/spew"
2222
"github.com/lightningnetwork/lnd/buffer"
23-
"github.com/lightningnetwork/lnd/build"
2423
"github.com/lightningnetwork/lnd/chainntnfs"
2524
"github.com/lightningnetwork/lnd/channeldb"
2625
"github.com/lightningnetwork/lnd/channeldb/models"
@@ -624,7 +623,7 @@ func NewBrontide(cfg Config) *Brontide {
624623
resentChanSyncMsg: make(map[lnwire.ChannelID]struct{}),
625624
startReady: make(chan struct{}),
626625
quit: make(chan struct{}),
627-
log: build.NewPrefixLog(logPrefix, peerLog),
626+
log: peerLog.WithPrefix(logPrefix),
628627
msgRouter: msgRouter,
629628
globalMsgRouter: globalMsgRouter,
630629
}

0 commit comments

Comments
 (0)