You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to figure out how to remove the "level" and "message" keys from log output and I couldn't find anything in the documentation.
After going through the source code, I found these lines in the JSON encoder's implementation of EncodeEntry:
iffinal.LevelKey!="" {
final.addKey(final.LevelKey)
cur:=final.buf.Len()
final.EncodeLevel(ent.Level, final)
ifcur==final.buf.Len() {
// User-supplied EncodeLevel was a no-op. Fall back to strings to keep// output JSON valid.final.AppendString(ent.Level.String())
}
}
While it works for our use case, this behavior isn't documented anywhere and the Encoder interface doesn't specify that it should do that. I'm worried that because of this, at some point it'll change and we'll have to reevaluate how we do this.
I'd like to submit a PR that adds this documentation to the Encoder interface, as well as a constant (like const OmitKey = "") to make this behavior explicitly part of the interface.
I wanted to get your feedback on this before submitting the PR.
The text was updated successfully, but these errors were encountered:
I was trying to figure out how to remove the
"level"
and"message"
keys from log output and I couldn't find anything in the documentation.After going through the source code, I found these lines in the JSON encoder's implementation of
EncodeEntry
:While it works for our use case, this behavior isn't documented anywhere and the
Encoder
interface doesn't specify that it should do that. I'm worried that because of this, at some point it'll change and we'll have to reevaluate how we do this.I'd like to submit a PR that adds this documentation to the
Encoder
interface, as well as a constant (likeconst OmitKey = ""
) to make this behavior explicitly part of the interface.I wanted to get your feedback on this before submitting the PR.
The text was updated successfully, but these errors were encountered: