Fork me on GitHub
#timbre
<
2022-12-13
>
pavlosmelissinos17:12:26

Hello, it's me again! Since I asked my last question we've decided to double down on timbre and replace the logging implementation in another project (pedestal + logback) with timbre, using https://github.com/fzakaria/slf4j-timbre. However, I've noticed a difference when using e.g. io.pedestal.log/info compared to taoensso.timbre/info. slf4j-timbre seems to be sending the pedestal logs to timbre as a string but that's too early because I'm using a modified version of https://github.com/viesti/timbre-json-appender/ (that I can't share unfortunately) to convert the logs to JSON and assoc the key value pairs to the final map. Here's an example of that:

(clojure.data.json/read-str (with-out-str (io.pedestal.log/info :msg "lala")))
  {"msg" "{:msg \"lala\", :line 1}", "timestamp" "2022-12-13T17:36:25Z", "level" "info", "thread" "nREPL-session-a20b4dae-bcda-465d-b781-bfa3416ba011", "hostname" "...", "file" "log.clj", "line" 116}
  
  (clojure.data.json/read-str (with-out-str (taoensso.timbre/info :msg "lala")))
  {"msg" "lala", "timestamp" "2022-12-13T17:36:54Z", "level" "info", "thread" "nREPL-session-a20b4dae-bcda-465d-b781-bfa3416ba011", "hostname" "..", "file" ".../dev.clj", "line" 1}
How can I make the first example look more like the second? I could explicitly try to convert every string coming to the JSON appender to EDN and then to JSON but that sounds ridiculously expensive. What are my alternatives, besides replacing io.pedestal.log requires with taoensso.timbre? edit: also pedestal seems to be reporting the wrong file/line -it's the io.pedestal.log namespace- but I can live with that Update: Doesn't seem to be possible, I decided to replace all the requires of io.pedestal.log with taoensso.timbre, which at least takes care of my logs. I don't care much about the ones deeper in the stack.