From ca23277d42db5a97ca20c010f7f55f7340bd568d Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 10 Jun 2023 19:26:21 -0700 Subject: [PATCH] fix #251 by adding timing mention to with-logging --- CHANGELOG.md | 1 + src/next/jdbc.clj | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b350794..3b33be9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Only accretive/fixative changes will be made from now on. * 1.3.next in progress * Address [#254](https://github.com/seancorfield/next-jdbc/issues/254) by adding `next.jdbc/active-tx?` and adding more explanation to [**Transactions**](https://cljdoc.org/d/com.github.seancorfield/next.jdbc/CURRENT/doc/getting-started/transactions) about the conventions behind transactions and the limitations of thread-local tracking of active transactions in `next.jdbc`. + * Address [#251](https://github.com/seancorfield/next-jdbc/issues/251) by updating `next.jdbc/with-logging` docstring. * 1.3.874 -- 2023-04-15 * Fix [#248](https://github.com/seancorfield/next-jdbc/issues/248) by allowing `:port` to be `:none`. diff --git a/src/next/jdbc.clj b/src/next/jdbc.clj index f61b0e8..4b8d49d 100644 --- a/src/next/jdbc.clj +++ b/src/next/jdbc.clj @@ -434,8 +434,13 @@ * `next.jdbc/plan`, `next.jdbc/execute-one!`, `next.jdbc/execute!`, or `next.jdbc/prepare` * the vector containing the SQL string and its parameters + Whatever the sql/params logging function returns will be passed as a - `state` argument to the optional result logging function. + `state` argument to the optional result logging function. This means you can + use this mechanism to provide some timing information, since your sql/params + logging function can return the current system time, and your result logging + function can then calculate the elapsed time. There is an example of this in + the Naive Logging with Timing section of Getting Started. The result logging function, if provided, will be called with the same symbol passed to the sql/params logging function, the `state`