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

Chore: Moving to slog (folders) #87000

Merged
merged 7 commits into from May 2, 2024
Merged

Chore: Moving to slog (folders) #87000

merged 7 commits into from May 2, 2024

Conversation

zserge
Copy link
Contributor

@zserge zserge commented Apr 26, 2024

This starts the migration of Grafana logging to stdlib's log/slog API.

Now instead of using pkg/infra/log one can rely on slog.Default() logger and its derivatives.

To make a logger with a custom logger name one should use slog.Default().With("logger", "mylogger").

For testing there is a no-op handler (logs produce no output) and a t.Log() wrapper (logs produce normal test output).

It's also possible to inject an slog.Handler() with Wire to build more customised loggers on top of it.

Following these practices would reduce the usage of pkg/infra/log a lot and would help with further modularisation of Grafana backend.

@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.1.x milestone Apr 26, 2024
@zserge zserge mentioned this pull request Apr 27, 2024
@zserge zserge marked this pull request as ready for review April 30, 2024 10:15
@zserge zserge requested review from a team as code owners April 30, 2024 10:15
@zserge zserge requested review from owensmallwood and papagian and removed request for a team April 30, 2024 10:15
@zserge zserge added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Apr 30, 2024
Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@zserge zserge merged commit 6ddb8ae into main May 2, 2024
12 checks passed
@zserge zserge deleted the zserge/slog branch May 2, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants