Pass FromContext(...) context to slog handler#425
Open
inteon wants to merge 2 commits intogo-logr:masterfrom
Open
Pass FromContext(...) context to slog handler#425inteon wants to merge 2 commits intogo-logr:masterfrom
FromContext(...) context to slog handler#425inteon wants to merge 2 commits intogo-logr:masterfrom
Conversation
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
…thContext Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
obarisk
reviewed
Mar 10, 2026
| // slog.LevelInfo and V(4) becomes slog.LevelDebug. | ||
| // | ||
| // The provided context is passed to the slog.Handler when logging. This allows | ||
| // the slog.Handler to use the context. This should only be used for short-lived |
There was a problem hiding this comment.
Would the following a little more descriptive?
an slog which following the lifecycle of the context
not limit to the vague long lived v.s. short lived
Author
There was a problem hiding this comment.
Could you provide a diff? I would like to understand exactly what you would like to change, as I think that the current comment is quite clear already.
|
following the context of #158 context of logger is not really helpful if we are going to take the information in context for log events with current implementation, we have to create logger for those events. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of passing
context.Background(), we now pass the context passed toFromContext(...)to the slog.Handle(...)function instead.This is an alternative solution to the problem presented in #158 (only solves the use case where an slog backend is used).
cc @pohly