Skip to content

refactor: migrate logging to Go slog#1552

Draft
ravisuhag wants to merge 2 commits intomainfrom
refactor/migrate-logging-to-slog
Draft

refactor: migrate logging to Go slog#1552
ravisuhag wants to merge 2 commits intomainfrom
refactor/migrate-logging-to-slog

Conversation

@ravisuhag
Copy link
Copy Markdown
Member

Summary

  • Replace go.uber.org/zap and github.com/raystack/salt/log with Go's standard library log/slog across the entire codebase (111 files)
  • Rewrite pkg/logger/ with slog-based InitLogger, ToContext, FromContext, and Fatal helpers
  • Remove external logging dependencies (go.uber.org/zap, grpc-zap-middleware) from go.mod

Details

Foundation (pkg/logger/):

  • InitLogger(cfg) returns *slog.Logger with JSON or text handler based on config
  • ToContext/FromContext replace grpczap.ToContext/Extract for request-scoped logging
  • Fatal helper wraps slog.Error + os.Exit(1) since slog has no Fatal level

Migration patterns applied:

Before After
log.Logger (salt interface) *slog.Logger
grpczap.ToContext(ctx, logger) frontierlogger.ToContext(ctx, logger)
grpczap.Extract(ctx) frontierlogger.FromContext(ctx)
zap.String("k", v) "k", v
zap.Error(err) "error", err
log.NewNoop() (tests) slog.New(slog.NewTextHandler(io.Discard, nil))

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go mod tidy clean
  • go test ./... (unit tests)
  • Manual smoke test: start server, verify structured logs appear
  • Verify no remaining imports of zap, salt/log, or ctxzap

Replace go.uber.org/zap and github.com/raystack/salt/log with log/slog
across the entire codebase. This removes external logging dependencies
in favor of Go's built-in structured logging introduced in Go 1.21.

Key changes:
- Rewrite pkg/logger with slog-based InitLogger, ToContext, FromContext
- Replace salt log.Logger interface with *slog.Logger throughout
- Replace grpczap context propagation with custom context helpers
- Convert all zap typed fields (zap.String, zap.Error) to key-value pairs
- Update Connect RPC logger interceptor to use *slog.Logger
- Update all tests to use slog with io.Discard handler
- Remove go.uber.org/zap and grpc-zap-middleware dependencies
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Apr 18, 2026 6:43am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 18, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: adc936d8-2ae5-40fd-b181-fa3d36fc00ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 18, 2026

Coverage Report for CI Build 24599076513

Coverage remained the same at 41.808%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 423 uncovered changes across 62 files (431 of 854 lines covered, 50.47%).
  • 23 coverage regressions across 15 files.

Uncovered Changes

Top 10 Files by Coverage Impact Changed Covered %
internal/api/v1beta1connect/role.go 53 7 13.21%
pkg/logger/logger.go 27 0 0.0%
internal/api/v1beta1connect/authorize.go 26 0 0.0%
internal/api/v1beta1connect/billing_customer.go 28 3 10.71%
internal/api/v1beta1connect/user.go 60 36 60.0%
pkg/server/connect_interceptors/logger.go 22 0 0.0%
internal/api/v1beta1connect/group.go 37 16 43.24%
internal/api/v1beta1connect/organization.go 49 30 61.22%
internal/api/v1beta1connect/authenticate.go 18 2 11.11%
internal/api/v1beta1connect/project.go 28 13 46.43%

Coverage Regressions

23 previously-covered lines in 15 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
internal/api/v1beta1connect/role.go 5 25.69%
internal/api/v1beta1connect/billing_product.go 2 63.78%
internal/api/v1beta1connect/organization.go 2 60.68%
internal/api/v1beta1connect/user.go 2 59.22%
pkg/server/connect_interceptors/logger.go 2 0.0%
internal/api/v1beta1connect/authenticate.go 1 22.57%
internal/api/v1beta1connect/billing_customer.go 1 6.67%
internal/api/v1beta1connect/billing_invoice.go 1 51.2%
internal/api/v1beta1connect/billing_subscription.go 1 15.98%
internal/api/v1beta1connect/billing_usage.go 1 61.74%

Coverage Stats

Coverage Status
Relevant Lines: 36900
Covered Lines: 15427
Line Coverage: 41.81%
Coverage Strength: 11.74 hits per line

💛 - Coveralls

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.

2 participants