Skip to content

Commit c4f7258

Browse files
authored
Improve LogPoller logs (#1440)
* Improved LogPoller logs * Lint
1 parent 4efe2a1 commit c4f7258

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

pkg/solana/logpoller/job_get_block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (j *getBlockJob) Run(ctx context.Context) error {
129129
events = append(events, txEvents...)
130130
}
131131

132-
j.lggr.Debugf("found %d events at slot %d", len(events), j.slotNumber)
132+
j.lggr.Debugw("found events", "count", len(events), "slot", j.slotNumber)
133133

134134
result := types.Block{
135135
SlotNumber: j.slotNumber,

pkg/solana/logpoller/log_poller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (lp *Service) Process(ctx context.Context, programEvent types.ProgramEvent)
230230
log.ExpiresAt = &expiresAt
231231
}
232232

233-
lp.lggr.Infof("found matching event %+v", log)
233+
lp.lggr.Infow("found matching event", "log", log, "eventName", filter.EventName)
234234

235235
logs = append(logs, log)
236236
}
@@ -409,7 +409,7 @@ consumedAllBlocks:
409409

410410
batch := []types.Block{block}
411411
batch = appendBuffered(blocks, blocksChBuffer, batch)
412-
lp.lggr.Infof("processing batch of %d blocks: [slots %d-%d]", len(batch), batch[0].SlotNumber, batch[len(batch)-1].SlotNumber)
412+
lp.lggr.Infow("processing batch of blocks", "count", len(batch), "start", batch[0].SlotNumber, "end", batch[len(batch)-1].SlotNumber)
413413
err = lp.processBlocks(ctx, batch)
414414
if err != nil {
415415
return fmt.Errorf("error processing blocks: %w", err)

pkg/solana/logpoller/types/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func (h Hash) ToSolana() solana.Hash {
6767
return solana.Hash(h)
6868
}
6969

70+
func (h Hash) String() string {
71+
return h.ToSolana().String()
72+
}
73+
7074
type Signature solana.Signature
7175

7276
// Scan implements Scanner for database/sql.
@@ -83,6 +87,10 @@ func (s Signature) ToSolana() solana.Signature {
8387
return solana.Signature(s)
8488
}
8589

90+
func (s Signature) String() string {
91+
return s.ToSolana().String()
92+
}
93+
8694
func scanFixedLengthArray(name string, maxLength int, src interface{}, dest []byte) error {
8795
srcB, ok := src.([]byte)
8896
if !ok {

0 commit comments

Comments
 (0)