refactor: replace direct slog usage with api.Logger in handlers#808
Open
sumitakhuli wants to merge 1 commit intoOneBusAway:mainfrom
Open
refactor: replace direct slog usage with api.Logger in handlers#808sumitakhuli wants to merge 1 commit intoOneBusAway:mainfrom
sumitakhuli wants to merge 1 commit intoOneBusAway:mainfrom
Conversation
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.
Description
Fixes #694
This PR refactors several REST API handlers to eliminate direct
slogusages and replace them with the contextualapi.Logger.Previously, some handlers bypassed the structured logging configuration by calling
slog.Warn(),slog.Info(), orslog.Error()directly, or by usingslog.Stringrather than passing alternating key-value string arguments to the context logger. This change enforces consistency with other handlers (e.g.,trips_for_route_handler.go) to ensure all log output routes properly through the*RestAPIreceiver.Changes Made
trip_details_handler.go: Replaced directslog.Warnevents mapped toapi.Logger.Warn. Removedslog.Stringwrappers in favor of variadic key-value arguments.report_problem_with_stop_handler.go&report_problem_with_trip_handler.go: Removed defaultslog.Default()fallbacks. Overhauledlogging.LogOperationandlogging.LogErrorlogic to invoke corresponding.Info()and.Error()calls cleanly ontoapi.Logger.trip_for_vehicle_handler_test.go,stops_for_route_handler_test.go): Swapped standardslog.Newlogger instantiations in favor oflogging.NewStructuredLogger, dropping thelog/slogimports across the rest api bounds.Acceptance Criteria Met
*_handler.gofiles ininternal/restapi/for directslogusage.slog.Warn(),slog.Info(),slog.Error()calls with the equivalentapi.Logger.Warn(),api.Logger.Info(),api.Logger.Error()calls.grep -r "slog\." internal/restapi/*handler*.goreturns exactly zero matches.make testpasses (confirmed logic & syntax integrity).make lintpasses.