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

pkg/log: fix panic when using custom Logger #4452

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

lukedirtwalker
Copy link
Collaborator

@lukedirtwalker lukedirtwalker commented Dec 6, 2023

log.FromCtx could panic if a custom Logger was used and a span was present in the context. This commit allows the custom logger to implement the WithOptions(...zap.Option) Logger method so that the CallerSkip can still be applied. In case the logger can't be casted to anything the caller skip is not applied, but we also don't panic anymore.


This change is Reviewable

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @matzf)

Copy link
Contributor

@matzf matzf left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lukedirtwalker)

@lukedirtwalker
Copy link
Collaborator Author

/rebase

log.FromCtx could panic if a custom Logger was used and a span was
present in the context. This commit allows the custom logger to
implement the `WithOptions(...zap.Option) Logger` method so that the
CallerSkip can still be applied. In case the logger can't be casted to
anything the caller skip is not applied, but we also don't panic
anymore.
@lukedirtwalker lukedirtwalker merged commit b4e65a6 into scionproto:master Dec 7, 2023
4 checks passed
@lukedirtwalker lukedirtwalker deleted the logger-panic branch December 7, 2023 08:31
juagargi pushed a commit to netsec-ethz/scion that referenced this pull request Mar 8, 2024
log.FromCtx could panic if a custom Logger was used and a span was
present in the context. This commit allows the custom logger to
implement the `WithOptions(...zap.Option) Logger` method so that the
CallerSkip can still be applied. In case the logger can't be casted to
anything the caller skip is not applied, but we also don't panic
anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants