-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
slogr: restore original backend when converting back and forth
This works both ways by checking whether the backend is one of our own wrappers. There's one exception: when the verbosity level was modified, we cannot use the original slog.Handler because it doesn't know about that modification. The downside is that we have to adjust the stack unwinding each time a record is handled, because we need the original sink without that adjustment. This only gets done when actually emitting a log record, so that overhead should be okay. It will disappear entirely once sinks directly support writing a slog.Event. A second copy would work, but then that copy would need to be updated alongside the other one in WithAttrs, which causes overhead along a callchain also when the log record does not get emitted. The code also would be more complex.
- Loading branch information
Showing
3 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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