Skip to content

Conversation

@onelapahead
Copy link
Contributor

In several case, one might want to set several key value pairs on the context. Currently you have to chain together nested WithLogField funcs to do so, which isn't very readable or user friendly.

This allows the users to do so with just a list of strings. Otherwise we could require a logrus.Fields struct to be directly provided if we want to avoid the odd-number-check-and-panic ?

return WithLogger(ctx, loggerFromContext(ctx).WithField(key, value))
}

func WithLogFields(ctx context.Context, keyValues ...string) context.Context {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having ...string is fine to be consistent with WithLogField but it doesn't stop us having logrus.Fields one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants