Add partial encoder #15
No reviewers
Labels
No labels
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/zapjournald#15
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/partial-encoder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Partial encoder is an encoder wrapper which ignores specific fields. This is useful with zapjournald core to ignore syslog fields
in human-readable console output.
Before:
After:
Syslog fields are still indexed.
To use encoder, just wrap partial encoder around console or any other encoder.
Encoder adds almost none overhead and even improves logging speed for entities with syslog fields.
f4efb4e3cf
to045b966ecb
Related to #14 but not sure it addresses exact issues.
@ -0,0 +16,4 @@
// NewPartialEncoder wraps existing encoder to avoid output of some provided
// fields. The main use case is to ignore SyslogFields that leak into
// ConsoleEncoder and provide no additional info for the human.
func NewPartialEncoder(enc zapcore.Encoder, ignore []string) zapcore.Encoder {
Here you write a wrapper. Have you considered the possibility of just copying relevant bits from another encoder and changing what is necessary (
zapjournald.Field
parameters are accepted but ignored instead of being printed).Oh, please, disregard, I have looked at
cmd/main.go
and it contains old code.