Skip to content

refactor: replace stdlib log with zap logger in devnet/funding.go#305

Open
cats2101 wants to merge 1 commit intoLayr-Labs:mainfrom
cats2101:fix/use-zap-logger-in-funding
Open

refactor: replace stdlib log with zap logger in devnet/funding.go#305
cats2101 wants to merge 1 commit intoLayr-Labs:mainfrom
cats2101:fix/use-zap-logger-in-funding

Conversation

@cats2101
Copy link
Copy Markdown

Motivation:
Closes #169.

pkg/common/devnet/funding.go used the stdlib log package directly, which bypassed the configured zap logger and (via log.Fatalf) could terminate the process mid-flow without letting callers handle the error.

Modifications:

  • Added an iface.Logger parameter to FundStakerWithTokens, FundStakersWithStrategyTokens, FundWalletsDevnet, and fundIfNeeded.
  • Replaced every log.Print* / log.Println with the matching logger.Info / logger.Warn / logger.Error.
  • Replaced the four log.Fatalf sites inside FundWalletsDevnet with wrapped errors via fmt.Errorf so the caller decides on termination.
  • Updated the existing call sites in pkg/commands/devnet_actions.go to forward the logger that is already in scope.
  • Removed the unused log import.

Result:
All output from the funding helpers now flows through the configured zap logger, and the operator-loop in FundWalletsDevnet can no longer abort the process when one operator's keystore is misconfigured.

Testing:

  • go build ./...
  • go vet ./...
  • go test ./pkg/common/devnet/...
  • golangci-lint run pkg/common/devnet/... pkg/commands/...
  • gofmt -l clean on both touched files.

Open questions:
None.

Closes Layr-Labs#169

The funding helpers in pkg/common/devnet/funding.go used the stdlib log
package, which bypasses the configured zap logger and (via log.Fatalf)
could exit the process mid-flow without giving callers a chance to
handle the error.

Plumb iface.Logger through FundStakerWithTokens, FundStakersWithStrategyTokens,
FundWalletsDevnet, and fundIfNeeded, and replace each log.Print* call
with the matching logger.Info/Warn/Error. The four log.Fatalf sites in
FundWalletsDevnet now return wrapped errors instead of calling os.Exit,
so the caller can decide what to do.

Updated the two callers in pkg/commands/devnet_actions.go to forward
the logger that already lives in that scope.
@cats2101 cats2101 requested a review from a team as a code owner April 18, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove log.Print use in devnet/funding.go

1 participant