h3poteto / logist

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

Simplifying lograge integration with Lograge::Formatters::Raw #19

Open md5 opened 3 years ago

md5 commented 3 years ago

While reviewing this gem in the context of implementing JSON-formatted structured logs for our applications, I noticed that it is currently setting config.lograge.formatter = Lograge::Formatters::Json.new, then parsing JSON in Logist::Formatter::Json#normalize_message before converting back to JSON. It seems like it would be simpler to instead use config.lograge.formatter = Lograge::Formatters::Raw.new and skip the parsing step in #normalize_message. Is there some reason I'm missing that it's done the way it is? I can't think of another source that would be sending stringified JSON to the Rails logger.