refactor: replace stdlib log with zap logger in devnet/funding.go#305
Open
cats2101 wants to merge 1 commit intoLayr-Labs:mainfrom
Open
refactor: replace stdlib log with zap logger in devnet/funding.go#305cats2101 wants to merge 1 commit intoLayr-Labs:mainfrom
cats2101 wants to merge 1 commit intoLayr-Labs:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
Closes #169.
pkg/common/devnet/funding.goused the stdliblogpackage directly, which bypassed the configured zap logger and (vialog.Fatalf) could terminate the process mid-flow without letting callers handle the error.Modifications:
iface.Loggerparameter toFundStakerWithTokens,FundStakersWithStrategyTokens,FundWalletsDevnet, andfundIfNeeded.log.Print*/log.Printlnwith the matchinglogger.Info/logger.Warn/logger.Error.log.Fatalfsites insideFundWalletsDevnetwith wrapped errors viafmt.Errorfso the caller decides on termination.pkg/commands/devnet_actions.goto forward the logger that is already in scope.logimport.Result:
All output from the funding helpers now flows through the configured zap logger, and the operator-loop in
FundWalletsDevnetcan 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 -lclean on both touched files.Open questions:
None.