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

slogr: restore original backend when converting back and forth #210

Merged
merged 1 commit into from
Aug 23, 2023

Commits on Aug 23, 2023

  1. 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.
    pohly committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    6964a54 View commit details
    Browse the repository at this point in the history