Skip to content

Commit a104567

Browse files
authored
Remove logging topics (#137)
* Remove logging topics * Pin Kondo version * Work around clj-kondo/clj-kondo#2026 * Cloverage: ignore namespaces we don't test in Cloverage
1 parent 5e92bc3 commit a104567

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+206
-237
lines changed

deps.edn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@
121121
toucan2.log/warnf]
122122

123123
:ns-regex
124-
["^toucan\\..*" "^toucan2\\..*"]}}
124+
["^toucan\\..*" "^toucan2\\..*"]
125+
126+
;; ignore namespaces we don't test with Cloverage.
127+
:ns-exclude-regex
128+
["^toucan2\\.query-execution-backend\\.jdbc\\.mysql-mariadb.*"
129+
"^toucan2\\.query-execution-backend\\.jdbc\\.postgres.*"]}}
125130

126131
;; clojure -T:build
127132
:build

scripts/lint-and-test-fast.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
set -euxo pipefail
66

7+
codespell
8+
79
clj-kondo --parallel --lint src test toucan1/src/ toucan1/test/
810

911
clojure -X:dev:test:test-h2 $@

scripts/lint-and-test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ set -euxo pipefail
1010

1111
codespell
1212

13+
clj-kondo --parallel --lint src test toucan1/src/ toucan1/test/
14+
1315
clojure -X:dev:test $@

src/toucan2/connection.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
(let [connectable-class (if (instance? pretty.core.PrettyPrintable connectable)
114114
(pretty/pretty connectable)
115115
(protocols/dispatch-value connectable))]
116-
(log/debugf :execute "Resolve connection %s" connectable-class)
116+
(log/debugf "Resolve connection %s" connectable-class)
117117
(u/try-with-error-context ["resolve connection" {::connectable connectable-class}]
118118
(next-method connectable (bind-current-connectable-fn f)))))
119119

@@ -264,14 +264,14 @@
264264
(m/defmethod do-with-transaction :around ::default
265265
"Bind [[*current-connectable*]] to the connection `f` is called with inside of `f`."
266266
[connection options f]
267-
(log/debugf :execute "do with transaction %s %s" options (some-> connection class .getCanonicalName symbol))
267+
(log/debugf "do with transaction %s %s" options (some-> connection class .getCanonicalName symbol))
268268
(next-method connection options (bind-current-connectable-fn f)))
269269

270270
(m/defmethod do-with-transaction java.sql.Connection
271271
[^java.sql.Connection conn options f]
272272
(let [nested-tx-rule (get options :nested-transaction-rule :allow)
273273
options (dissoc options :nested-transaction-rule)]
274-
(log/debugf :execute "do with JDBC transaction (nested rule: %s) with options %s" nested-tx-rule options)
274+
(log/debugf "do with JDBC transaction (nested rule: %s) with options %s" nested-tx-rule options)
275275
(binding [next.jdbc.transaction/*nested-tx* nested-tx-rule]
276276
(next.jdbc/with-transaction [t-conn conn options]
277277
(f t-conn)))))

src/toucan2/insert.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
(let [rows (some (comp not-empty :rows) [parsed-args resolved-query])]
6666
(if (can-skip-insert? parsed-args resolved-query)
6767
(do
68-
(log/debugf :compile "Query has no changes, skipping update")
68+
(log/debugf "Query has no changes, skipping update")
6969
::pipeline/no-op)
7070
(do
71-
(log/debugf :compile "Inserting %s rows into %s" (if (seq rows) (count rows) "?") model)
71+
(log/debugf "Inserting %s rows into %s" (if (seq rows) (count rows) "?") model)
7272
(next-method query-type model parsed-args resolved-query)))))
7373

7474
(defn insert!

src/toucan2/jdbc/query.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,29 @@
2828
opts (merge (when-not (:return-keys opts)
2929
read-forward-options)
3030
opts)]
31-
(log/debugf :execute "Preparing JDBC query with next.jdbc options %s" opts)
31+
(log/debugf "Preparing JDBC query with next.jdbc options %s" opts)
3232
(u/try-with-error-context [(format "execute SQL with %s" (class conn)) {::sql-args sql-args}]
3333
(with-open [stmt (next.jdbc/prepare conn sql-args opts)]
3434
(when-not (= (.getFetchDirection stmt) ResultSet/FETCH_FORWARD)
3535
(try
3636
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
3737
(catch Throwable e
38-
(log/debugf :results e "Error setting fetch direction"))))
39-
(log/tracef :execute "Executing statement with %s" (class conn))
38+
(log/debugf e "Error setting fetch direction"))))
39+
(log/tracef "Executing statement with %s" (class conn))
4040
(let [result-set? (.execute stmt)]
4141
(cond
4242
(:return-keys opts)
4343
(do
44-
(log/debugf :execute "Query was executed with %s; returning generated keys" :return-keys)
44+
(log/debugf "Query was executed with %s; returning generated keys" :return-keys)
4545
(with-open [rset (.getGeneratedKeys stmt)]
4646
(jdbc.rs/reduce-result-set rf init conn model rset opts)))
4747

4848
result-set?
4949
(with-open [rset (.getResultSet stmt)]
50-
(log/debugf :execute "Query returned normal result set")
50+
(log/debugf "Query returned normal result set")
5151
(jdbc.rs/reduce-result-set rf init conn model rset opts))
5252

5353
:else
5454
(do
55-
(log/debugf :execute "Query did not return a ResultSet; nothing to reduce. Returning update count.")
55+
(log/debugf "Query did not return a ResultSet; nothing to reduce. Returning update count.")
5656
(reduce rf init [(.getUpdateCount stmt)]))))))))

src/toucan2/jdbc/read.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
{:arglists '([^Connection conn₁ model₂ ^ResultSet rset ^ResultSetMetaData rsmeta₍₃₎ ^Long i])}
4444
(fn [^Connection conn model _rset ^ResultSetMetaData rsmeta ^Long i]
4545
(let [col-type (.getColumnType rsmeta i)]
46-
(log/debugf :results
46+
(log/debugf
4747
"Column %s %s is of JDBC type %s, native type %s"
4848
i
4949
(let [table-name (some->> (.getTableName rsmeta i) not-empty)
@@ -57,9 +57,9 @@
5757

5858
(m/defmethod read-column-thunk :default
5959
[_conn _model ^ResultSet rset _rsmeta ^Long i]
60-
(log/debugf :results "Fetching values in column %s with %s" i (list '.getObject 'rs i))
60+
(log/debugf "Fetching values in column %s with %s" i (list '.getObject 'rs i))
6161
(fn default-read-column-thunk []
62-
(log/tracef :results "col %s => %s" i (list '.getObject 'rset i))
62+
(log/tracef "col %s => %s" i (list '.getObject 'rset i))
6363
(.getObject rset i)))
6464

6565
(m/defmethod read-column-thunk :after :default
@@ -78,7 +78,7 @@
7878
7979
but includes extra logging."
8080
[^ResultSet rset ^Long i ^Class klass]
81-
(log/debugf :results
81+
(log/debugf
8282
"Fetching values in column %s with %s"
8383
i
8484
(list '.getObject 'rs i klass))
@@ -88,7 +88,7 @@
8888
;; from Criterium: a no-op call takes about 20ns locally. So 10m rows => 200ms from this no-op call. That's a little
8989
;; expensive, but probably not as bad as the overhead we get from other nonsense here in Toucan 2. We'll have to do
9090
;; some general performance tuning in the future.
91-
(log/tracef :results "col %s => %s" i (list '.getObject 'rset i klass))
91+
(log/tracef "col %s => %s" i (list '.getObject 'rset i klass))
9292
(.getObject rset i klass)))
9393

9494
;;;; Default column read methods
@@ -119,7 +119,7 @@
119119
(get-object-of-class-thunk rset i java.time.OffsetTime))
120120

121121
(defn- make-column-thunk [conn model ^ResultSet rset i]
122-
(log/tracef :results "Building thunk to read column %s" i)
122+
(log/tracef "Building thunk to read column %s" i)
123123
(fn column-thunk []
124124
(let [rsmeta (.getMetaData rset)
125125
thunk (read-column-thunk conn model rset rsmeta i)
@@ -164,7 +164,7 @@
164164
(fn cached-column-thunk []
165165
(let [cached-value (get @cached-values i ::not-found)]
166166
(if-not (= cached-value ::not-found)
167-
(log/tracef :results "Using cached value for column %s: %s" i cached-value)
167+
(log/tracef "Using cached value for column %s: %s" i cached-value)
168168
cached-value)
169169
(let [thunk (i->thunk i)
170170
v (thunk)]
@@ -197,5 +197,5 @@
197197
(let [i->thunk (row-num->i->thunk (.getRow rset))
198198
thunk (i->thunk i)
199199
result (thunk)]
200-
(log/tracef :results "col %s => %s" i result)
200+
(log/tracef "col %s => %s" i result)
201201
result))))

src/toucan2/jdbc/result_set.clj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
(defrecord ^:no-doc InstanceBuilder [model ^ResultSet rset ^ResultSetMetaData rsmeta cols]
3838
next.jdbc.rs/RowBuilder
3939
(->row [_this]
40-
(log/tracef :results "Fetching row %s" (.getRow rset))
40+
(log/tracef "Fetching row %s" (.getRow rset))
4141
(transient (instance/instance model)))
4242

4343
(column-count [_this]
@@ -55,7 +55,7 @@
5555
(assoc! row col v))
5656

5757
(row! [_this row]
58-
(log/tracef :results "Converting transient row to persistent row")
58+
(log/tracef "Converting transient row to persistent row")
5959
(persistent! row))
6060

6161
next.jdbc.rs/ResultSetBuilder
@@ -89,9 +89,9 @@
8989
(when (= col column-name')
9090
(inc i)))
9191
cols)))]
92-
(log/tracef :results "Index of column named %s (originally %s) is %s" column-name' column-name i)
92+
(log/tracef "Index of column named %s (originally %s) is %s" column-name' column-name i)
9393
(when-not i
94-
(log/debugf :results "Could not determine index of column name %s. Found: %s" column-name cols))
94+
(log/debugf "Could not determine index of column name %s. Found: %s" column-name cols))
9595
i))))))
9696

9797
(defn instance-builder-fn
@@ -105,15 +105,15 @@
105105
(fn [table]
106106
(let [table (some-> table not-empty name label-fn)
107107
table-ns (some-> (get table-name->ns table) name)]
108-
(log/tracef :results "Using namespace %s for columns in table %s" table-ns table)
108+
(log/tracef "Using namespace %s for columns in table %s" table-ns table)
109109
table-ns)))
110110
opts (merge {:label-fn label-fn
111111
:qualifier-fn qualifier-fn}
112112
opts)
113113
rsmeta (.getMetaData rset)
114-
_ (log/debugf :results "Getting modified column names with next.jdbc options %s" opts)
114+
_ (log/debugf "Getting modified column names with next.jdbc options %s" opts)
115115
col-names (next.jdbc.rs/get-modified-column-names rsmeta opts)]
116-
(log/debugf :results "Column names: %s" col-names)
116+
(log/debugf "Column names: %s" col-names)
117117
(constantly
118118
(assoc (->InstanceBuilder model rset rsmeta col-names) :opts opts))))
119119

@@ -131,7 +131,7 @@
131131
Part of the low-level implementation of the JDBC query execution backend -- you probably shouldn't be using this
132132
directly."
133133
[rf init conn model ^ResultSet rset opts]
134-
(log/debugf :execute "Reduce JDBC result set for model %s with rf %s and init %s" model rf init)
134+
(log/debugf "Reduce JDBC result set for model %s with rf %s and init %s" model rf init)
135135
(let [row-num->i->thunk (jdbc.read/make-cached-row-num->i->thunk conn model rset)
136136
builder-fn* (next.jdbc.rs/builder-adapter
137137
(builder-fn conn model rset opts)
@@ -144,16 +144,16 @@
144144
(.getMetaData rset)
145145
combined-opts))
146146
col-name->index (make-column-name->index col-names label-fn)]
147-
(log/tracef :results "column name -> index = %s" col-name->index)
147+
(log/tracef "column name -> index = %s" col-name->index)
148148
(loop [acc init]
149149
(b/cond
150150
(not (.next rset))
151151
(do
152-
(log/tracef :results "Result set has no more rows.")
152+
(log/tracef "Result set has no more rows.")
153153
acc)
154154

155155
:let [row-num (.getRow rset)
156-
_ (log/tracef :results "Fetch row %s" row-num)
156+
_ (log/tracef "Fetch row %s" row-num)
157157
i->thunk (row-num->i->thunk row-num)
158158
row (jdbc.row/row model rset builder i->thunk col-name->index)
159159
acc' (rf acc row)]

src/toucan2/jdbc/row.clj

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
:let [thunk (i->thunk i)]
3535
(not thunk) not-found
3636
:else (thunk))]
37-
(log/tracef :results "=> %s" result)
37+
(log/tracef "=> %s" result)
3838
result))
3939

4040
(def ^:private ^:dynamic *fetch-all-columns* true)
@@ -71,7 +71,7 @@
7171

7272
clojure.lang.IPersistentMap
7373
(assoc [this k v]
74-
(log/tracef :results ".assoc %s %s" k v)
74+
(log/tracef ".assoc %s %s" k v)
7575
(if @already-realized?
7676
(assoc @realized-row k v)
7777
(let [^clojure.lang.ITransientMap transient-row' (assoc! transient-row k v)]
@@ -99,11 +99,11 @@
9999

100100
;; TODO -- can we `assocEx` the transient row?
101101
(assocEx [_this k v]
102-
(log/tracef :results ".assocEx %s %s" k v)
102+
(log/tracef ".assocEx %s %s" k v)
103103
(.assocEx ^clojure.lang.IPersistentMap @realized-row k v))
104104

105105
(without [this k]
106-
(log/tracef :results ".without %s" k)
106+
(log/tracef ".without %s" k)
107107
(if @already-realized?
108108
(dissoc @realized-row k)
109109
(let [transient-row' (dissoc! transient-row k)]
@@ -127,31 +127,31 @@
127127
;; TODO -- not sure if we need/want this
128128
java.lang.Iterable
129129
(iterator [_this]
130-
(log/tracef :results ".iterator")
130+
(log/tracef ".iterator")
131131
(.iterator ^java.lang.Iterable @realized-row))
132132

133133
clojure.lang.Associative
134134
(containsKey [_this k]
135-
(log/tracef :results ".containsKey %s" k)
135+
(log/tracef ".containsKey %s" k)
136136
(boolean (column-name->index k)))
137137

138138
(entryAt [this k]
139-
(log/tracef :results ".entryAt %s" k)
139+
(log/tracef ".entryAt %s" k)
140140
(let [v (.valAt this k ::not-found)]
141141
(when-not (= v ::not-found)
142142
(clojure.lang.MapEntry. k v))))
143143

144144
;;; TODO -- this should probably also include any extra keys added with `assoc` or whatever
145145
clojure.lang.Counted
146146
(count [_this]
147-
(log/tracef :results ".count")
147+
(log/tracef ".count")
148148
(let [cols (:cols builder)]
149149
(assert (seq cols))
150150
(count cols)))
151151

152152
clojure.lang.IPersistentCollection
153153
(cons [this o]
154-
(log/tracef :results ".cons %s" o)
154+
(log/tracef ".cons %s" o)
155155
(cond
156156
(map? o)
157157
(reduce #(apply assoc %1 %2) this o)
@@ -165,21 +165,21 @@
165165
this)))
166166

167167
(empty [_this]
168-
(log/tracef :results ".empty")
168+
(log/tracef ".empty")
169169
(instance/instance model))
170170

171171
(equiv [_this obj]
172-
(log/tracef :results ".equiv %s" obj)
172+
(log/tracef ".equiv %s" obj)
173173
(.equiv ^clojure.lang.IPersistentCollection @realized-row obj))
174174

175175
;; we support get with a numeric key for array-based builders:
176176
clojure.lang.ILookup
177177
(valAt [this k]
178-
(log/tracef :results ".valAt %s" k)
178+
(log/tracef ".valAt %s" k)
179179
(.valAt this k nil))
180180

181181
(valAt [this k not-found]
182-
(log/tracef :results ".valAt %s %s" k not-found)
182+
(log/tracef ".valAt %s %s" k not-found)
183183
(cond
184184
@already-realized?
185185
(get @realized-row k not-found)
@@ -205,26 +205,26 @@
205205
;; we support nth for array-based builderset (i is primitive int here!):
206206
;; clojure.lang.Indexed
207207
;; (nth [_this i]
208-
;; (log/tracef :results ".nth %s" i)
208+
;; (log/tracef ".nth %s" i)
209209
;; (try
210210
;; (i->thunk (inc i))
211211
;; (catch java.sql.SQLException _)))
212212
;; (nth [_this i not-found]
213-
;; (log/tracef :results ".nth %s %s" i not-found)
213+
;; (log/tracef ".nth %s %s" i not-found)
214214
;; (try
215215
;; (i->thunk (inc i))
216216
;; (catch java.sql.SQLException _
217217
;; not-found)))
218218

219219
clojure.lang.Seqable
220220
(seq [_this]
221-
(log/tracef :results ".seq")
221+
(log/tracef ".seq")
222222
(seq @realized-row))
223223

224224
;; calling [[persistent!]] on a transient row will convert it to a persistent object WITHOUT realizing all the columns.
225225
clojure.lang.ITransientCollection
226226
(persistent [_this]
227-
(log/tracef :results ".persistent")
227+
(log/tracef ".persistent")
228228
(binding [*fetch-all-columns* false]
229229
@realized-row))
230230

@@ -254,7 +254,7 @@
254254

255255
protocols/IDeferrableUpdate
256256
(deferrable-update [this k f]
257-
(log/tracef :results "Doing deferrable update of %s with %s" k f)
257+
(log/tracef "Doing deferrable update of %s with %s" k f)
258258
(b/cond
259259
@already-realized?
260260
(update @realized-row k f)
@@ -339,15 +339,15 @@
339339
transient-row)))
340340

341341
(defn- fetch-all-columns! [builder i->thunk transient-row]
342-
(log/tracef :results "Fetching all columns")
342+
(log/tracef "Fetching all columns")
343343
(reduce
344344
(partial fetch-column! builder i->thunk)
345345
transient-row
346346
(range 1 (inc (next.jdbc.rs/column-count builder)))))
347347

348348
(defn- make-realized-row-delay [builder i->thunk transient-row]
349349
(delay
350-
(log/tracef :results "Fully realizing row. *fetch-all-columns* = %s" *fetch-all-columns*)
350+
(log/tracef "Fully realizing row. *fetch-all-columns* = %s" *fetch-all-columns*)
351351
(let [row (cond->> transient-row
352352
*fetch-all-columns* (fetch-all-columns! builder i->thunk))]
353353
(next.jdbc.rs/row! builder row))))

0 commit comments

Comments
 (0)