slog icon indicating copy to clipboard operation
slog copied to clipboard

Add "tag" and "location" fields to JSON logger

Open Diggsey opened this issue 5 years ago • 3 comments

The JSON logger has a set of "default" fields that it outputs: https://github.com/slog-rs/json/blob/master/lib.rs#L320.

However, RecordStatic contains several additional useful fields (tag and location) which are not logged.

Diggsey avatar Mar 19 '19 14:03 Diggsey

I commented on a PR. Basically - for backward compt. reason we can't just modify that function. Users already can add whatever they want manually, and just because more information is avilable, does not necessary mean all users want to log everything all the time.

dpc avatar Mar 21 '19 19:03 dpc

What do you mean "users can already add whatever they want manually"? This information is captured internally by the logging macros - in many cases those macros will be called from 3rd party code. There's no way for a user to manually add this information back in.

If any changes to the log output are a breaking change, then that seems like a design issue with this crate - perhaps there could be a constructor taking a "version" argument? Or at least some configuration to allow adding more fields?

Diggsey avatar Mar 21 '19 21:03 Diggsey

What do you mean "users can already add whatever they want manually"?

add_key_value is a public function. There is nothing special about add_default_keys. Anything that add_default_keys can do, user can do too, without it. All the code you've added in https://github.com/slog-rs/json/pull/17/files , you can call from the outside and get the behavior of that PR, even if I don't land this PR.

Therefore there's no point is over-complicating things.

dpc avatar Mar 22 '19 22:03 dpc