Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace cdr.dev/slog with stdlib slog #7451

Closed as not planned
Closed as not planned
@ammario

Description

@ammario

With the advent of Go's official slog to be released in 1.21, it's clear that our slog is outdated and should be retired. The std slog's API is more ergonomic and we should expect the Go ecosystem to centralize around it, as it has done with most other standard library packages.

Fortunately, there is a graceful migration path for Coder:

  • Replace Human JSON output with logfmt, used by std slog, zerolog, and others. This will improve performance by ~10x and make our output far more readable.
  • Add a kvlog.Logger type that wraps a slog.Logger with a keyAndArgs ...interface{} calling signature, so we can migrate portions of our codebase to the .Info("some message", "user_id", userID") format adopted by std slog.
  • Lower priority: remove context from Log calls where unnecessary

This approach gives us optionality. If std slog fails or is rejected, we get some nice API improvements. If it succeeds, moving to a the new logger is 90% search-and-replace and far less risky.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions