Skip to content

logging: replace slog(fmt.Sprintf) with structured fields #706

Description

@wolf31o2

Goal

Standardize on structured slog logging across the codebase. Today some call sites use slog.Error(fmt.Sprintf(...)), which loses structured fields and makes log processing harder.

Files (audit)

  • input/chainsync/*.go
  • output/*/*.go
  • filter/*/*.go
  • api/*.go

Changes

Replace slog.Error(fmt.Sprintf(...)) and similar patterns with structured field calls. Where a logger lacks a component context, attach one via slog.With("component", "<name>").

// before
slog.Error(fmt.Sprintf("failed to process %s: %v", item, err))

// after
slog.Error("failed to process item", "item", item, "error", err)

Apply the same pattern to slog.Warn and slog.Info call sites that interpolate via fmt.Sprintf.

Verification

go build ./...
golangci-lint run
grep -rEn 'slog\.[A-Za-z]+\(fmt\.Sprintf' --include='*.go'

The grep should produce no output.

Dependencies

None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions