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.
You could, if perhaps you're using postgresql, set the log level directly on the driver
Or, you could simply decorate the function that invokes the next.jdbc function ,i.e., execute-one, with a simple "log/tracef" call
(I do the latter)
@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.
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.
yep, I'm using postgresql. I may need to google how to do that, not sure yet.
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).
got it. Thank you @seancorfield
You can see some of that experiment in an old version of the tests https://github.com/seancorfield/next-jdbc/blob/eda9c93a1c9077f127e2cf6434b5174635ea073c/test/next/jdbc/middleware_test.clj#L22
The next.jdbc.middleware
namespace no longer exists (and nor does that test).
But it was ugly/complex to use in that state. I've learned from that 🙂
<https://github.com/pgjdbc/pgjdbc>
loggerLevel
and loggerFile
Thank you David! 🙏