feat: modify slog.Logger to *not* satisfy slog.Sink #95
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.
The prior implementation allowed slog.Logger instances
to themselves be passes as slog.Sink targets. This enabled
many usage patterns that introduced extremely counter-intuitive
behavior.
This isn't just an aesthetics problem, but has caused real confusion in our monorepo. Consider the following case:
Because of the nesting here, where
log
is aslog.Logger
passed as aslog.Sink
, the metadata between these two sink targets will be different. That can have unexpected behavior, like in this case logs tosomeOtherSink
could have a different logger name than those logged tolog
.As a solution, this PR modifes
slog.Logger
to not satisfyslog.Sink
. This is a much simpler mental model... sinks are the primitive and loggers are higher-level that also hold metadata. Loggers also being sinks themselves creates more confusion than value.To suite this particular use cases, whereby a child wants to extend a logger with an additional sinks, we should instead expose the following method