Skip to content

Commit

Permalink
more logger name cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Aug 31, 2023
1 parent b7bcf20 commit 3985505
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion common/txmgr/confirmer.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) bat
}
}

lggr := ec.lggr.Named("batchFetchReceipts").With("blockNum", blockNum)
lggr := ec.lggr.Named("BatchFetchReceipts").With("blockNum", blockNum)

txReceipts, txErrs, err := ec.client.BatchGetReceipts(ctx, attempts)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions common/txmgr/reaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewReaper[CHAIN_ID types.ID](lggr logger.Logger, store txmgrtypes.TxHistory
config,
txConfig,
chainID,
lggr.Named("txm_reaper"),
lggr.Named("Reaper"),
atomic.Int64{},
make(chan struct{}, 1),
make(chan struct{}),
Expand All @@ -43,13 +43,13 @@ func NewReaper[CHAIN_ID types.ID](lggr logger.Logger, store txmgrtypes.TxHistory

// Start the reaper. Should only be called once.
func (r *Reaper[CHAIN_ID]) Start() {
r.log.Debugf("TxmReaper: started with age threshold %v and interval %v", r.txConfig.ReaperThreshold(), r.txConfig.ReaperInterval())
r.log.Debugf("started with age threshold %v and interval %v", r.txConfig.ReaperThreshold(), r.txConfig.ReaperInterval())
go r.runLoop()
}

// Stop the reaper. Should only be called once.
func (r *Reaper[CHAIN_ID]) Stop() {
r.log.Debug("TxmReaper: stopping")
r.log.Debug("stopping")
close(r.chStop)
<-r.chDone
}
Expand Down Expand Up @@ -79,7 +79,7 @@ func (r *Reaper[CHAIN_ID]) work() {
}
err := r.ReapTxes(latestBlockNum)
if err != nil {
r.log.Error("TxmReaper: unable to reap old txes: ", err)
r.log.Error("unable to reap old txes: ", err)
}
}

Expand All @@ -99,20 +99,20 @@ func (r *Reaper[CHAIN_ID]) SetLatestBlockNum(latestBlockNum int64) {
func (r *Reaper[CHAIN_ID]) ReapTxes(headNum int64) error {
threshold := r.txConfig.ReaperThreshold()
if threshold == 0 {
r.log.Debug("TxmReaper: Transactions.ReaperThreshold set to 0; skipping ReapTxes")
r.log.Debug("Transactions.ReaperThreshold set to 0; skipping ReapTxes")
return nil
}
minBlockNumberToKeep := headNum - int64(r.config.FinalityDepth())
mark := time.Now()
timeThreshold := mark.Add(-threshold)

r.log.Debugw(fmt.Sprintf("TxmReaper: reaping old txes created before %s", timeThreshold.Format(time.RFC3339)), "ageThreshold", threshold, "timeThreshold", timeThreshold, "minBlockNumberToKeep", minBlockNumberToKeep)
r.log.Debugw(fmt.Sprintf("reaping old txes created before %s", timeThreshold.Format(time.RFC3339)), "ageThreshold", threshold, "timeThreshold", timeThreshold, "minBlockNumberToKeep", minBlockNumberToKeep)

if err := r.store.ReapTxHistory(minBlockNumberToKeep, timeThreshold, r.chainID); err != nil {
return err
}

r.log.Debugf("TxmReaper: ReapTxes completed in %v", time.Since(mark))
r.log.Debugf("ReapTxes completed in %v", time.Since(mark))

return nil
}
2 changes: 1 addition & 1 deletion core/chains/cosmos/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (c *chain) getClient(name string) (cosmosclient.ReaderWriter, error) {
return nil, fmt.Errorf("failed to create client for chain %s with node %s: wrong chain id %s", c.id, name, node.CosmosChainID)
}
}
client, err := cosmosclient.NewClient(c.id, node.TendermintURL, DefaultRequestTimeout, logger.Named(c.lggr, "Client-"+name))
client, err := cosmosclient.NewClient(c.id, node.TendermintURL, DefaultRequestTimeout, logger.Named(c.lggr, "Client."+name))
if err != nil {
return nil, errors.Wrap(err, "failed to create client")
}
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/client/null_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type nullSubscription struct {
}

func newNullSubscription(lggr logger.Logger) *nullSubscription {
return &nullSubscription{lggr: lggr.Named("nullSubscription")}
return &nullSubscription{lggr: lggr.Named("NullSubscription")}
}

func (ns *nullSubscription) Unsubscribe() {
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/monitor/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (bm *balanceMonitor) updateBalance(ethBal assets.Eth, address gethCommon.Ad
bm.ethBalances[address] = &ethBal
bm.ethBalancesMtx.Unlock()

lgr := bm.logger.Named("balance_log").With(
lgr := bm.logger.Named("BalanceLog").With(
"address", address.Hex(),
"ethBalance", ethBal.String(),
"weiBalance", ethBal.ToInt())
Expand Down
2 changes: 1 addition & 1 deletion core/chains/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (c *chain) verifiedClient(node db.Node) (client.ReaderWriter, error) {
expectedChainID: c.id,
}
// create client
cl.ReaderWriter, err = client.NewClient(url, c.cfg, DefaultRequestTimeout, logger.Named(c.lggr, "Client-"+node.Name))
cl.ReaderWriter, err = client.NewClient(url, c.cfg, DefaultRequestTimeout, logger.Named(c.lggr, "Client."+node.Name))
if err != nil {
return nil, errors.Wrap(err, "failed to create client")
}
Expand Down
2 changes: 1 addition & 1 deletion core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (n ChainlinkAppFactory) NewApplication(ctx context.Context, cfg chainlink.G

dbListener := cfg.Database().Listener()
eventBroadcaster := pg.NewEventBroadcaster(cfg.Database().URL(), dbListener.MinReconnectInterval(), dbListener.MaxReconnectDuration(), appLggr, cfg.AppID())
loopRegistry := plugins.NewLoopRegistry(appLggr.Named("LoopRegistry"))
loopRegistry := plugins.NewLoopRegistry(appLggr)

// create the relayer-chain interoperators from application configuration
relayerFactory := chainlink.RelayerFactory{
Expand Down
2 changes: 1 addition & 1 deletion core/internal/cltest/cltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn
keyStore := keystore.New(db, utils.FastScryptParams, lggr, cfg.Database())

mailMon := utils.NewMailboxMonitor(cfg.AppID().String())
loopRegistry := plugins.NewLoopRegistry(lggr.Named("LoopRegistry"))
loopRegistry := plugins.NewLoopRegistry(lggr)

relayerFactory := chainlink.RelayerFactory{
Logger: lggr,
Expand Down
5 changes: 3 additions & 2 deletions core/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ type Logger interface {
With(args ...interface{}) Logger
// Named creates a new Logger sub-scoped with name.
// Names are inherited and dot-separated.
// a := l.Named("a") // logger=a
// b := a.Named("b") // logger=a.b
// a := l.Named("A") // logger=A
// b := a.Named("A") // logger=A.B
// Names are generally `MixedCaps`, without spaces, like Go names.
Named(name string) Logger

// SetLogLevel changes the log level for this and all connected Loggers.
Expand Down
2 changes: 1 addition & 1 deletion core/services/blockhashstore/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (d *Delegate) ServicesForSpec(jb job.Job, qopts ...pg.QOpt) ([]job.ServiceC
return nil, errors.Wrap(err, "building bulletproof bhs")
}

log := d.logger.Named("BHS Feeder").With("jobID", jb.ID, "externalJobID", jb.ExternalJobID)
log := d.logger.Named("BHSFeeder").With("jobID", jb.ID, "externalJobID", jb.ExternalJobID)
feeder := NewFeeder(
log,
NewMultiCoordinator(coordinators...),
Expand Down
2 changes: 1 addition & 1 deletion core/services/blockheaderfeeder/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (d *Delegate) ServicesForSpec(jb job.Job, qopts ...pg.QOpt) ([]job.ServiceC
return nil, errors.Wrap(err, "building batchBHS")
}

log := d.logger.Named("Block Header Feeder").With(
log := d.logger.Named("BlockHeaderFeeder").With(
"jobID", jb.ID,
"externalJobID", jb.ExternalJobID,
"bhsAddress", bhs.Address(),
Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
// we need to initialize in case we serve OCR2 LOOPs
loopRegistry := opts.LoopRegistry
if loopRegistry == nil {
loopRegistry = plugins.NewLoopRegistry(globalLogger.Named("LoopRegistry"))
loopRegistry = plugins.NewLoopRegistry(globalLogger)
}

// If the audit logger is enabled
Expand Down
2 changes: 1 addition & 1 deletion core/services/functions/connector_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewFunctionsConnectorHandler(nodeAddress string, signerKey *ecdsa.PrivateKe
storage: storage,
allowlist: allowlist,
rateLimiter: rateLimiter,
lggr: lggr.Named("functionsConnectorHandler"),
lggr: lggr.Named("FunctionsConnectorHandler"),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion core/services/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewGateway(codec api.Codec, httpServer gw_net.HttpServer, handlers map[stri
httpServer: httpServer,
handlers: handlers,
connMgr: connMgr,
lggr: lggr.Named("gateway"),
lggr: lggr.Named("Gateway"),
}
httpServer.SetHTTPRequestHandler(gw)
return gw
Expand Down
6 changes: 3 additions & 3 deletions core/services/nurse.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ const (
func NewNurse(cfg Config, log logger.Logger) *Nurse {
return &Nurse{
cfg: cfg,
log: log.Named("nurse"),
log: log.Named("Nurse"),
checks: make(map[string]CheckFunc),
chGather: make(chan gatherRequest, 1),
chStop: make(chan struct{}),
}
}

func (n *Nurse) Start() error {
return n.StartOnce("nurse", func() error {
return n.StartOnce("Nurse", func() error {
// This must be set *once*, and it must occur as early as possible
if n.cfg.MemProfileRate() != runtime.MemProfileRate {
runtime.MemProfileRate = n.cfg.BlockProfileRate()
Expand Down Expand Up @@ -137,7 +137,7 @@ func (n *Nurse) Start() error {
}

func (n *Nurse) Close() error {
return n.StopOnce("nurse", func() error {
return n.StopOnce("Nurse", func() error {
n.log.Debug("Nurse closing...")
defer n.log.Debug("Nurse closed")
close(n.chStop)
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (d *Delegate) ServicesForSpec(jb job.Job, qopts ...pg.QOpt) (services []job

enhancedTelemChan := make(chan ocrcommon.EnhancedTelemetryData, 100)
if ocrcommon.ShouldCollectEnhancedTelemetry(&jb) {
enhancedTelemService := ocrcommon.NewEnhancedTelemetryService(&jb, enhancedTelemChan, make(chan struct{}), d.monitoringEndpointGen.GenMonitoringEndpoint(concreteSpec.ContractAddress.String(), synchronization.EnhancedEA), lggr.Named("Enhanced Telemetry"))
enhancedTelemService := ocrcommon.NewEnhancedTelemetryService(&jb, enhancedTelemChan, make(chan struct{}), d.monitoringEndpointGen.GenMonitoringEndpoint(concreteSpec.ContractAddress.String(), synchronization.EnhancedEA), lggr.Named("EnhancedTelemetry"))
services = append(services, enhancedTelemService)
}

Expand Down
4 changes: 2 additions & 2 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (d *Delegate) newServicesMercury(
mercuryServices, err2 := mercury.NewServices(jb, mercuryProvider, d.pipelineRunner, runResults, lggr, oracleArgsNoPlugin, d.cfg.JobPipeline(), chEnhancedTelem, chain, d.mercuryORM, (mercuryutils.FeedID)(*spec.FeedID))

if ocrcommon.ShouldCollectEnhancedTelemetryMercury(&jb) {
enhancedTelemService := ocrcommon.NewEnhancedTelemetryService(&jb, chEnhancedTelem, make(chan struct{}), d.monitoringEndpointGen.GenMonitoringEndpoint(spec.FeedID.String(), synchronization.EnhancedEAMercury), lggr.Named("Enhanced Telemetry Mercury"))
enhancedTelemService := ocrcommon.NewEnhancedTelemetryService(&jb, chEnhancedTelem, make(chan struct{}), d.monitoringEndpointGen.GenMonitoringEndpoint(spec.FeedID.String(), synchronization.EnhancedEAMercury), lggr.Named("EnhancedTelemetryMercury"))
mercuryServices = append(mercuryServices, enhancedTelemService)
}

Expand Down Expand Up @@ -594,7 +594,7 @@ func (d *Delegate) newServicesMedian(
medianServices, err2 := median.NewMedianServices(ctx, jb, d.isNewlyCreatedJob, relayer, d.pipelineRunner, runResults, lggr, oracleArgsNoPlugin, mConfig, enhancedTelemChan, errorLog)

if ocrcommon.ShouldCollectEnhancedTelemetry(&jb) {
enhancedTelemService := ocrcommon.NewEnhancedTelemetryService(&jb, enhancedTelemChan, make(chan struct{}), d.monitoringEndpointGen.GenMonitoringEndpoint(spec.ContractID, synchronization.EnhancedEA), lggr.Named("Enhanced Telemetry"))
enhancedTelemService := ocrcommon.NewEnhancedTelemetryService(&jb, enhancedTelemChan, make(chan struct{}), d.monitoringEndpointGen.GenMonitoringEndpoint(spec.ContractID, synchronization.EnhancedEA), lggr.Named("EnhancedTelemetry"))
medianServices = append(medianServices, enhancedTelemService)
}

Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/plugins/threshold/decryption_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewDecryptionQueue(maxQueueLength int, maxCiphertextBytes int, maxCiphertex
make(map[string]pendingRequest),
make(map[string]completedRequest),
sync.RWMutex{},
lggr.Named("decryptionQueue"),
lggr.Named("DecryptionQueue"),
}
return &dq
}
Expand Down
5 changes: 3 additions & 2 deletions core/services/relay/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ type CSAETHKeystore interface {
}

func NewRelayer(db *sqlx.DB, chain evm.Chain, cfg pg.QConfig, lggr logger.Logger, ks CSAETHKeystore, eventBroadcaster pg.EventBroadcaster) *Relayer {
lggr = lggr.Named("Relayer")
return &Relayer{
db: db,
chain: chain,
lggr: lggr.Named("Relayer"),
lggr: lggr,
ks: ks,
mercuryPool: wsrpc.NewPool(lggr.Named("Mercury.WSRPCPool")),
mercuryPool: wsrpc.NewPool(lggr),
eventBroadcaster: eventBroadcaster,
pgCfg: cfg,
}
Expand Down
2 changes: 1 addition & 1 deletion core/services/relay/evm/mercury/wsrpc/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ type pool struct {
}

func NewPool(lggr logger.Logger) Pool {
p := newPool(lggr)
p := newPool(lggr.Named("Mercury.WSRPCPool"))
p.newClient = NewClient
return p
}
Expand Down
2 changes: 1 addition & 1 deletion core/services/s4/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ Storage = (*storage)(nil)

func NewStorage(lggr logger.Logger, contraints Constraints, orm ORM, clock utils.Clock) Storage {
return &storage{
lggr: lggr.Named("s4_storage"),
lggr: lggr.Named("S4Storage"),
contraints: contraints,
orm: orm,
clock: clock,
Expand Down
6 changes: 3 additions & 3 deletions core/sessions/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ type orm struct {
var _ ORM = (*orm)(nil)

func NewORM(db *sqlx.DB, sd time.Duration, lggr logger.Logger, cfg pg.QConfig, auditLogger audit.AuditLogger) ORM {
namedLogger := lggr.Named("SessionsORM")
lggr = lggr.Named("SessionsORM")
return &orm{
q: pg.NewQ(db, namedLogger, cfg),
q: pg.NewQ(db, lggr, cfg),
sessionDuration: sd,
lggr: lggr.Named("SessionsORM"),
lggr: lggr,
auditLogger: auditLogger,
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/loop_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type LoopRegistry struct {
func NewLoopRegistry(lggr logger.Logger) *LoopRegistry {
return &LoopRegistry{
registry: map[string]*RegisteredLoop{},
lggr: lggr,
lggr: logger.Named(lggr, "LoopRegistry"),
}
}

Expand Down

0 comments on commit 3985505

Please sign in to comment.