chore: simplify, modernize (Go 1.26), update deps#87
Conversation
- doc.go: fix stale reference to "zap logger" (uses log/slog) - rpc.go: use LogAttrs+[]slog.Attr instead of []any accumulator; propagate ctx through ErrorContext/InfoContext/WarnContext/DebugContext; replace parallel format/formatRaw impls with shared buildAttrs helper; use strings.Join for comma-join in formatRaw; ensure Log/LogWithContext append a trailing newline so lines do not run together on stderr - rpc_test.go: update formatRaw/LogWithContext assertions for new \n suffix
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR migrates the app-logger RPC service from context-less logging to Go's Changesslog migration and newline normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR modernizes the app-logger RPC implementation around log/slog, simplifies attribute formatting, and adjusts raw stderr logging so emitted messages are newline-terminated.
Changes:
- Swaps leveled logger calls to context-aware
slogAPIs andLogAttrs. - Replaces
[]anyattribute formatting with typed[]slog.Attr. - Updates raw stderr formatting/tests and fixes stale package documentation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
rpc.go |
Modernizes slog calls, refactors attribute helpers, and changes stderr newline handling. |
rpc_test.go |
Updates raw formatting expectations for newline-terminated output. |
doc.go |
Updates package documentation from zap to log/slog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #87 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 57 62 +5
=========================================
+ Hits 57 62 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- LogWithContext: the no-attrs path now appends a trailing newline only
when missing (via shared ensureNewline helper), matching Log. Avoids a
blank line for already newline-terminated messages, e.g.
LogWithContext("hello\n", nil).
- rpc.go: reword the formatRaw comment that wrongly claimed it uses
buildAttrs (it does not; buildAttrs yields slog.Attr, not key:value text).
- rpc_test.go: cover the newline-idempotent no-args case.
776f503 replaced the strings.Builder (added in 2d880ab) with a pairs []string + strings.Join form under a "simplify" label, regressing formatRaw from ~1 allocation to N+3 per raw LogWithContext write. Restore the single-buffer Builder; output (one trailing newline, ':'/',' separators) and TestFormatRaw are unchanged.
Applied fixes
R (bug/correctness) — 1
rpc.goLog/LogWithContext: ensure each write to stderr ends with\n; without it consecutive messages run together on the same line.S (simplify) — 2
rpc.go: replace parallelformat/formatRawimplementations with a sharedbuildAttrshelper; eliminate the separateformatfunction.rpc.goformatRaw: replace hand-rolled comma-join loop withstrings.Join.M (modern Go 1.26) — 2
doc.go: fix stale doc comment that said "zap logger" — the plugin useslog/slog.rpc.go: replace[]anyaccumulator + variadicError/Info/Warn/Debugwith[]slog.Attr+LogAttrs; propagate caller context viaErrorContext/InfoContext/WarnContext/DebugContext.Deps
go get -u all && go mod tidyin root andtests/;go work sync. No version changes detected (already current).Summary by CodeRabbit
sloglogger with enhanced context support for RPC operations, enabling better request tracing and debugging capabilities.