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

Provide a way to exclude fields from ConsoleWriter #204

Closed
hach-que opened this issue Dec 8, 2019 · 0 comments · Fixed by #383
Closed

Provide a way to exclude fields from ConsoleWriter #204

hach-que opened this issue Dec 8, 2019 · 0 comments · Fixed by #383

Comments

@hach-que
Copy link

hach-que commented Dec 8, 2019

For example, you can set up ConsoleWriter in such a way that custom fields are in PartsOrder, like this:

output := zerolog.ConsoleWriter{Out: os.Stderr}
output.PartsOrder = []string{
	zerolog.TimestampFieldName,
	zerolog.LevelFieldName,
	"node",
	zerolog.MessageFieldName,
}

logger := zerolog.New(output).With().Timestamp().Str("node", node).Logger()
return &logger

However, there's no way of excluding the custom field from then being duplicated in the writeFields call. In addition, there's no way to control the rendering of custom fields in PartsOrder for e.g. adding padding for alignment.

The feature request is thus:

  • Provide a way to exclude fields in the ConsoleWriter, or automatically exclude fields from writeFields if the field is specified in PartsOrder (the latter makes the most sense to me).
  • ConsoleWriter.FormatFieldValue should have the field name passed to it, so that the presentation of those custom fields can be modified correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants