Fix phsym/zeroslog breakage due to rs/zerolog v1.32.0 #653
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.
TL;DR Add function to create a zerolog.Context object with a logger copy and clear the copy's context byte array in order to fix breakage in
phsym/zeroslog
.The recent release of
rs/zerolog v1.32.0
brokephsym/zeroslog
. The latter was creating blankzerolog.Context
objects in several places and they worked fine up throughrs/zerolog v1.31.0
. I documented the issue in aphsym/zeroslog
PR, wherein I provided a potential solution to the issue that didn't require any changes tors/zerolog
.This PR provides a (hopefully) minor change to
rs/zerolog
that makes fixingphsym/zeroslog
simpler. I have already filed a second presumptivephsym/zeroslog
PR dependent on the changes in thisrs/zerolog
PR.Hopefully this PR will be an acceptable and minor change.
I gave the new function a long name because it is combining two issues. It could be broken down into:
NewContext(logger Logger)
which would just create the new
zerolog.Context
object with a logger and(l Logger) ClearContext()
which would clear the
context
byte array on the copiedLogger
.These two calls could be used instead of the single
NewContextWithResetLogger
call, something like this:If the latter is preferable I can generate a different PR.