fix: standardize logging in trip_details_handler#701
fix: standardize logging in trip_details_handler#701Deepak8858 wants to merge 1 commit intoOneBusAway:mainfrom
Conversation
|
Deepak Singh seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
Hey @Deepak8858, welcome to Maglev and great start! 🎉 I'm a fellow contributor here, and I wanted to drop a quick review to help you get this PR ready for the maintainers. You correctly fixed the
Let me know if you need any help with this, happy to help you get it merged! |
aaronbrethorst
left a comment
There was a problem hiding this comment.
Hey Deepak, nice instinct picking this up — logging consistency is one of those things that matters more than people think. You've correctly identified the two slog.Warn calls in trip_details_handler.go and swapped them to api.Logger.Warn. That's the right fix for those lines.
However, this PR doesn't yet satisfy the acceptance criteria in issue #694. Let me walk you through what's still needed.
Critical Issues
1. Incomplete scope — issue #694 requires auditing all handler files
The issue's acceptance criteria state:
- Audit all
*_handler.gofiles ininternal/restapi/for directslogusagegrep -r "slog\." internal/restapi/*handler*.goreturns zero matches
Running that grep today still returns 26 matches across three handler files. Here's what still needs fixing:
trip_details_handler.go (this PR's file) — the slog.Warn calls are fixed, but slog.String(...) is still used as structured attrs on lines 165-166 and 175-176. Per the issue context, the pattern to follow is api.Logger.Warn("message", "key", value) with plain key-value pairs instead of slog.String(). Once you do that, you can drop the "log/slog" import entirely.
report_problem_with_stop_handler.go — uses slog.Default() on line 16 and slog.String(...) throughout.
report_problem_with_trip_handler.go — same pattern: slog.Default() on line 16 and slog.String(...) throughout.
2. slog.String usage keeps the log/slog import alive
Even after your change, trip_details_handler.go still imports "log/slog" because slog.String() is used as a log attribute. The acceptance criteria require zero slog. matches in handler files. Replace:
api.Logger.Warn("BuildTripStatus failed",
slog.String("trip_id", trip.ID),
slog.String("error", statusErr.Error()))with:
api.Logger.Warn("BuildTripStatus failed",
"trip_id", trip.ID,
"error", statusErr.Error())This lets you remove the "log/slog" import from this file.
Important Notes
Out-of-scope files also have slog usage
trips_helper.go has ~10 direct slog.Warn() calls (lines 67, 125, 259, 276, 292, 517, 530, 548, 996, 1013), and rate_limit_middleware.go uses slog.Default(). These aren't *_handler* files, so they're technically outside the grep check in #694's acceptance criteria. I'd suggest noting them in the PR description as follow-up work but keeping this PR focused on the handler files.
CLA needs signing
The CLA bot is flagging your PR. You'll need to link your commit email to your GitHub account and sign the CLA before this can be merged.
Suggestions
- Fellow contributor @tejasva-vardhan already left great feedback — their comment covers the same issues I've noted. Follow their guidance and you'll be in good shape.
Recommended Action: Request Changes
- Convert
slog.String("key", value)to plain"key", valuepairs intrip_details_handler.goand remove the"log/slog"import - Apply the same fixes to
report_problem_with_stop_handler.goandreport_problem_with_trip_handler.go - Verify
grep -r "slog\." internal/restapi/*handler*.goreturns zero matches - Run
make testandmake lint - Sign the CLA
This PR replaces direct
slog.Warncalls withapi.Logger.Warnininternal/restapi/trip_details_handler.gofor consistency with other handlers and to ensure structured logging configuration is respected.\n\nFixes #694