routing: prefix MC logs with namespace

This commit is contained in:
Elle Mouton 2024-08-13 19:01:42 +02:00
parent f0f4f2df21
commit 5eff056933
No known key found for this signature in database
GPG key ID: D7D916376026F177

View file

@ -7,7 +7,9 @@ import (
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btclog"
"github.com/btcsuite/btcwallet/walletdb"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/fn"
@ -127,6 +129,8 @@ type MissionControl struct {
// mission control state is updated.
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
log btclog.Logger
mu sync.Mutex
}
@ -270,10 +274,14 @@ func NewMissionController(db kvdb.Backend, self route.Vertex,
// Create a mission control in the default namespace.
defaultMC := &MissionControl{
cfg: mcCfg,
state: newMissionControlState(cfg.MinFailureRelaxInterval),
store: store,
estimator: cfg.Estimator,
cfg: mcCfg,
state: newMissionControlState(cfg.MinFailureRelaxInterval),
store: store,
estimator: cfg.Estimator,
log: build.NewPrefixLog(
fmt.Sprintf("[%s]:", DefaultMissionControlNamespace),
log,
),
onConfigUpdate: cfg.OnConfigUpdate,
}
@ -310,7 +318,7 @@ func (m *MissionController) StopStoreTicker() {
// init initializes mission control with historical data.
func (m *MissionControl) init() error {
log.Debugf("Mission control state reconstruction started")
m.log.Debugf("Mission control state reconstruction started")
m.mu.Lock()
defer m.mu.Unlock()
@ -326,7 +334,7 @@ func (m *MissionControl) init() error {
_ = m.applyPaymentResult(result)
}
log.Debugf("Mission control state reconstruction finished: "+
m.log.Debugf("Mission control state reconstruction finished: "+
"n=%v, time=%v", len(results), time.Since(start))
return nil
@ -361,7 +369,7 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
m.mu.Lock()
defer m.mu.Unlock()
log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
m.log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
cfg.Estimator)
m.store.maxRecords = cfg.MaxMcHistory
@ -388,7 +396,7 @@ func (m *MissionControl) ResetHistory() error {
m.state.resetHistory()
log.Debugf("Mission control history cleared")
m.log.Debugf("Mission control history cleared")
return nil
}
@ -420,7 +428,7 @@ func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
m.mu.Lock()
defer m.mu.Unlock()
log.Debugf("Requesting history snapshot from mission control")
m.log.Debugf("Requesting history snapshot from mission control")
return m.state.getSnapshot()
}
@ -438,12 +446,12 @@ func (m *MissionControl) ImportHistory(history *MissionControlSnapshot,
m.mu.Lock()
defer m.mu.Unlock()
log.Infof("Importing history snapshot with %v pairs to mission control",
len(history.Pairs))
m.log.Infof("Importing history snapshot with %v pairs to mission "+
"control", len(history.Pairs))
imported := m.state.importSnapshot(history, force)
log.Infof("Imported %v results to mission control", imported)
m.log.Infof("Imported %v results to mission control", imported)
return nil
}
@ -567,7 +575,7 @@ func (m *MissionControl) applyPaymentResult(
// that case, a node-level failure would not be applied to untried
// channels.
if i.nodeFailure != nil {
log.Debugf("Reporting node failure to Mission Control: "+
m.log.Debugf("Reporting node failure to Mission Control: "+
"node=%v", *i.nodeFailure)
m.state.setAllFail(*i.nodeFailure, result.timeReply)
@ -577,11 +585,11 @@ func (m *MissionControl) applyPaymentResult(
pairResult := pairResult
if pairResult.success {
log.Debugf("Reporting pair success to Mission "+
m.log.Debugf("Reporting pair success to Mission "+
"Control: pair=%v, amt=%v",
pair, pairResult.amt)
} else {
log.Debugf("Reporting pair failure to Mission "+
m.log.Debugf("Reporting pair failure to Mission "+
"Control: pair=%v, amt=%v",
pair, pairResult.amt)
}