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

Support for a kv-generating interface on log arguments #142

Open
decibel opened this issue Jan 20, 2018 · 0 comments
Open

Support for a kv-generating interface on log arguments #142

decibel opened this issue Jan 20, 2018 · 0 comments

Comments

@decibel
Copy link

decibel commented Jan 20, 2018

Use case:
I've got a number of pre-defined logging keys that our code should be using; some mandatory, some optional. Since this is a complete set, it would be best to use a struct to define them; that way there's no chance of fat-fingering key names (is it Stack or StackTrace??).

My thought is that an interface like...

type KeyValuer interface {
    KeyValues() []interface{}
}

would satisfy what Record.Ctx wants, and could be identified while processing log arguments. Basically, this would be an exposed version of what Ctx.toArray() does. I think this would also satisfy #25.

A guess another option would be to write a handler that detects when it's been handed a KeyValuer, but that has the disadvantage of requiring the user to still provide some kind of key to keep the number of arguments even.

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

No branches or pull requests

1 participant