Open adamw opened 1 month ago
Yes; you should be able to set your log level to DEBUG, which will log all sql queries. Please let me know if that's not working.
https://github.com/AugustNagro/magnum?tab=readme-ov-file#logging-sql-queries
logSql is used here for example:
On Fri, Jul 26, 2024, 9:53 AM Adam Warski @.***> wrote:
Is there a way to (configurably) log the generated SQL queries, or log queries which are slow to execute?
There are some logSql functions in util, but they seem unused.
— Reply to this email directly, view it on GitHub https://github.com/AugustNagro/magnum/issues/32, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQOKNTUF65YJDJRJOXQRTDZOJPHPAVCNFSM6AAAAABLQVQJIWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTENBRGM3TOMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Ah! Finally got it to work. Turns out that private val Log = System.getLogger(getClass.getName)
will create a logger for scala.Predef
, instead of com.augustnagro.magnum
- what I was expecting in my logback config file. I suppose this should rather be the magnum's package?
Also, it would be great to have some kind of "interceptor" - logSql
is fine for basic logging, but for more advanced use cases (like logging slow queries), or plugging in some metrics - an interceptor would be needed I think.
create a logger for scala.Predef, instead of com.augustnagro.magnum - what I was expecting in my logback config file. I suppose this should rather be the magnum's package?
Yes.. that's a bug; thanks for raising!
"interceptor"
Open to adding as well. Do you have an example in mind?
On Wed, Jul 31, 2024, 9:13 AM Adam Warski @.***> wrote:
Ah! Finally got it to work. Turns out that private val Log = System.getLogger(getClass.getName) will create a logger for scala.Predef, instead of com.augustnagro.magnum - what I was expecting in my logback config file. I suppose this should rather be the magnum's package?
Also, it would be great to have some kind of "interceptor" - logSql is fine for basic logging, but for more advanced use cases (like logging slow queries), or plugging in some metrics - an interceptor would be needed I think.
— Reply to this email directly, view it on GitHub https://github.com/AugustNagro/magnum/issues/32#issuecomment-2260626990, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQOKNRRZNS3YRARIHGX6OLZPDWJHAVCNFSM6AAAAABLQVQJIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRQGYZDMOJZGA . You are receiving this because you commented.Message ID: @.***>
I was using Doobie's LogHandler
before and it worked well: https://github.com/tpolecat/doobie/blob/d1f84e64b026c0989818546c935c879e5dcc3598/modules/free/src/main/scala/doobie/util/log.scala#L122
So maybe something similar, passed as parameter to transact
- just as connectionConfig
is passed now?
Is there a way to (configurably) log the generated SQL queries, or log queries which are slow to execute?
There are some
logSql
functions inutil
, but they seem unused.