pedestal

gtbono 2024-05-31T13:59:06.064709Z

hey folks! about pedestal logging, I want each request to log a "context-id" that is the same for every log in that same request. Is there a recommended way of doing this with Pedestal?

Peterson Vieira Salme 2024-05-31T16:36:49.281619Z

I think this is what you need: http://pedestal.io/api/0.7/io.pedestal.log.html#var-with-context

gtbono 2024-05-31T19:48:49.335899Z

hey! thanks for the link, maybe it is but I'm unsure how to use it, is it an option that I pass to the log function?

hlship 2024-05-31T23:05:31.307169Z

Essentially, it sets up the SLF4J MDC. The MDC is an additional bit of data that a Logback appender (or whatever you are using) is formatting a message. Yes, that's obtuse. It's also painful, because the SLF4J MDC is in a ThreadLocal, but not one that Clojure knows about, so if you get to a different thread, you may lose the MDC. Or the MDC can leak data from one thread to another when the thread is reused.

hlship 2024-05-31T23:05:43.029719Z

I took a crack at this long before I was involved with Pedestal: https://github.com/AvisoNovate/logging

hlship 2024-05-31T23:07:45.957019Z

So I think a better solution would be an MDC supported by Pedestal that would merge with the particular log event before beeing converted to a string and passed down into SLF4J's api.

hlship 2024-05-31T23:07:55.669399Z

That could be added in 0.8.

➕ 3
gtbono 2024-06-01T02:12:58.562509Z

Is there something I could use with the current version of pedestal? even if it involves using a different logging library with it. I tried using https://github.com/AvisoNovate/logging and it didn't work (or maybe I used it wrong)