Skip to content

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

@decibel

Description

@decibel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions