Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: Introduce Log Levels Using slog for Enhanced Logging Granularity #2901

Open
tuunit opened this issue Jan 5, 2025 · 0 comments
Open

Comments

@tuunit
Copy link
Member

tuunit commented Jan 5, 2025

Summary

This RFC proposes introducing log levels to the project's logging mechanism to provide greater granularity and control over log outputs. The implementation will leverage the Go slog library introduced in Go 1.21, inspired by the logr interface. This change will facilitate improved debugging, monitoring, and operational insights, especially for large-scale deployments.

Background

Currently, the project uses the standard Go logging package log for all logging needs. While functional, this approach lacks support for log levels, making it challenging to differentiate between critical errors, warnings, informational messages, and debug details.

As the project has grown, this limitation has made logs harder to parse and has increased noise and complicating debugging and monitoring efforts.

The slog library, designed for structured logging, provides a robust framework for introducing log levels. It aligns well with modern logging needs and is compatible with the logr interface, commonly used in Kubernetes and other ecosystems.

Proposal

This RFC proposes:

  1. Adopting slog: Replace the standard log package with the slog library for logging.
  2. Introducing Log Levels: Define log levels:
    • Debug: Detailed diagnostic information for development or analyzing issues
    • Info: General operational messages that highlight application flow.
    • Error: Severe issues that require immediate attention.
  3. Structured Logging: Leverage slog's support for structured logging to include key-value pairs in logs for easier parsing and analysis.
  4. Configuration: Add a mechanism for configuring log levels at runtime, defaulting to Info for production builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant