-
I was trying to have some common fields in all logs and I used i.e. func fnA() {
logger = logger.With(zap.String("s", "sth"))
ctx = NewContext(ctx, logger)
fnB(ctx)
}
func fnB(ctx) {
logger = FromContext(ctx)
logger.Info("s", "else")
} the log from |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @3tbraden. Yeah, this is a fair question. There's also been some prior discussion about this in #622. |
Beta Was this translation helpful? Give feedback.
Hey @3tbraden. Yeah, this is a fair question.
Part of the reason for the choice is this: it's difficult to get the performance we want out of Zap by doing this with replace.
Particularly, note that
With
encodes keys at the timelogger.With
is called.Going back and changing what's already been encoded to fix a duplicate would require decoding and re-encoding that blob.
There's also been some prior discussion about this in #622.