h3poteto / logist

A json logger for Rails
MIT License
26 stars 9 forks source link

Logging a hash as flat json #16

Closed greyblake closed 4 years ago

greyblake commented 4 years ago

Hi, we're using logist, thanks for this library.

We'd like to be able to log hashes like this:

Rails.logger(foo: 'bar', xyz: 'abc')

Currently the resulted output is a nested JSON:

{"level": "INFO", "message": {"foo": "bar", "xyz":"abc" }}

What is reasonable.

However to be able parse and index the logs properly we need all this logged attributes to be on top level (not a nested JSON), like:

{"level": "INFO",  "foo": "bar", "xyz":"abc" }

I'd like to open PR to add flat_json (boolean) configuration option for Logger and Formatter. Would you be possibly to accept and merge such PR?

Thanks in advance.