Skip to content

Commit

Permalink
Move printlns to dev.clj
Browse files Browse the repository at this point in the history
  • Loading branch information
gpind committed Jun 21, 2023
1 parent 58472b2 commit c760756
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
24 changes: 16 additions & 8 deletions src/malli/dev.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"Stops instrumentation for all functions vars and removes clj-kondo type annotations."
[]
(remove-watch @#'m/-function-schemas* ::watch)
(mi/unstrument!)
(->> (mi/unstrument!)
count
(format "unstrumented %d vars")
println)
(clj-kondo/save! {})
(println "stopped instrumentation"))

Expand All @@ -22,13 +25,18 @@
(with-out-str (stop!))
(mi/collect! {:ns (all-ns)})
(let [watch (fn [_ _ old new]
(mi/instrument! (assoc options :data (->> (for [[n d] (:clj new)
:let [no (get-in old [:clj n])]
[s d] d
:when (not= d (get no s))]
[[n s] d])
(into {})
(reduce-kv assoc-in {}))))
(->> (for [[n d] (:clj new)
:let [no (get-in old [:clj n])]
[s d] d
:when (not= d (get no s))]
[[n s] d])
(into {})
(reduce-kv assoc-in {})
(assoc options :data)
mi/instrument!
count
(format "instrumented %d vars")
println)
(clj-kondo/emit!))]
(add-watch @#'m/-function-schemas* ::watch watch))
(mi/instrument! options)
Expand Down
8 changes: 2 additions & 6 deletions src/malli/instrument.clj
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,10 @@
"Applies instrumentation for a filtered set of function Vars (e.g. `defn`s).
See [[malli.core/-instrument]] for possible options."
([] (instrument! nil))
([options]
(doto (-strument! (assoc options :mode :instrument))
(->> count (format "Instrumented %d vars") println))))
([options] (-strument! (assoc options :mode :instrument))))

(defn unstrument!
"Removes instrumentation from a filtered set of function Vars (e.g. `defn`s).
See [[malli.core/-instrument]] for possible options."
([] (unstrument! nil))
([options]
(doto (-strument! (assoc options :mode :unstrument))
(->> count (format "Unstrumented %d vars") println))))
([options] (-strument! (assoc options :mode :unstrument))))

0 comments on commit c760756

Please sign in to comment.