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

Explore what key/value support should look like in fern #63

Open
daboross opened this issue Jun 5, 2020 · 0 comments
Open

Explore what key/value support should look like in fern #63

daboross opened this issue Jun 5, 2020 · 0 comments

Comments

@daboross
Copy link
Owner

daboross commented Jun 5, 2020

As of rust-lang/log#324, there's unstable support for key/value pairs in logging in log. For more information, see the tracking issue.

We probably want some amount of builtin support for key/value pairs in fern. It's unclear, though, exactly what form this support should take.

Some initial ideas:

  • filtering based on key values or keys being present
  • ability to add, remove and change keys while formatting
  • ability to output log messages, with key/value pairs & message, as JSON or others
  • some default way to incorporate kv pairs into formatting (might be a recipe?)

A more invasive setup could be:

  • add a new KeyValueDispatch dispatch type
    • can be created by specifying a function from (arguments, record) to key/value pairs
      • pushes responsibility onto user to decide what key "message" and "log level" end up as
      • we'd provide a sane default which maps all the record's fields to sane names, maybe namespaced
  • add the combinators from Dispatch to KeyValueDispatch, of course each giving/accepting a KeyValueDispatch instead
  • replace format with map - a general kv map with the same principles
  • replace output's single argument with multiple: one specifying a format (like newline-separated JSON), the other specifying where to write it

I'm not committed to any of these, this is just initial brainstorming.

We'll probably want to look at what one can do with key/value pairs in logging configuration in slog too, as they've explored this problem space a lot more than we have.

@daboross daboross mentioned this issue Jun 5, 2020
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant