Fork me on GitHub
#sql
<
2020-08-10
>
nick19:08:26

Is there a way to log all SQL requests performed by next.jdbc(and/or hugsql/honeysql)? I really enjoyed that feature in other languages/similar tools, really handy for debugging and spotting actions that generate too many SQL requests.

dharrigan19:08:16

You could, if perhaps you're using postgresql, set the log level directly on the driver

dharrigan19:08:31

Or, you could simply decorate the function that invokes the next.jdbc function ,i.e., execute-one, with a simple "log/tracef" call

dharrigan19:08:35

(I do the latter)

seancorfield20:08:08

@nfedyashev The primary reason that there isn't a way to do that is that everyone's logging needs are different so there's really no "one size fits all" thing the library could do for you.

seancorfield20:08:56

I had started experimenting with some sort of interceptor approach for next.jdbc that would let you hook into execute! both before and after an operation but it was very hard to provide a clean API that didn't also add overhead for everyone, even if they're not using it.

seancorfield20:08:14

I think, now I have with-options available, I might be able to use a similar approach to do logging -- but it would have the same caveats that with-options has: you need to manually propagate it across transactions and certain other calls (because next.jdbc uses native Java objects for improved performance).

nick20:08:25

got it. Thank you @seancorfield

seancorfield20:08:23

The next.jdbc.middleware namespace no longer exists (and nor does that test).

seancorfield20:08:50

But it was ugly/complex to use in that state. I've learned from that 🙂