Skip to content

Commit 063251d

Browse files
committed
[mod] [BREAKING] Change default min-level
Default before this commit: 2 Default after this commit: :info (equivalent to integer 50) Motivation: Tufte v2 levels were integers in #{0 1 2 3 4 5} Tufte v3 levels are ARBITRARY integers OR special keywords that are mapped to integers as: { :trace 10 :debug 20 :info 50 :warn 60 :error 70 :fatal 80 :report 90 :low--- 0 :low-- 10 :low- 20 :low 30 :med 50 :high 60 :high+ 70 :high++ 80 :high+++ 90} The new levels are more expressive, and are shared exactly by Telemere. Migration: This change won't affect you unless you have `profiled` or `profile` calls with custom `:level` values. If you DO have custom `:level` values then either: Ensure that you call `set-min-level!`, etc. to set an appropriate minmimum. -OR- Update your `profiled` and `profile` calls to use an appropriate `:level`.
1 parent d683dd3 commit 063251d

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/taoensso/tufte.cljc

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
`p`, `profiled`, `profile`, `add-handler!`, etc.
1515
1616
(p [opts & body] [id & body]) ; e.g. `(p ::my-id (do-work))`
17-
(profiled [opts & body]) ; e.g. `(profiled {:level 2} (my-fn))`
18-
(profile [opts & body]) ; e.g. `(profiled {:level 2} (my-fn))`
17+
(profiled [opts & body]) ; e.g. `(profiled {:level :info} (my-fn))`
18+
(profile [opts & body]) ; e.g. `(profiled {:level :info} (my-fn))`
1919
2020
(add-handler! [handler-id handler-fn dispatch-opts])
2121
@@ -101,11 +101,6 @@
101101
(impl/defhelp help:signal-content :signal-content)
102102
(impl/defhelp help:environmental-config :environmental-config))
103103

104-
;;;; Vestigial
105-
106-
(def ^:dynamic *min-level* "Vestigial, currently ignored." 2)
107-
(def ^:dynamic *ns-filter* "Vestigial, currently ignored." "*")
108-
109104
;;;; Low-level primitives
110105

111106
(defn profiling? "Returns e/o #{nil :thread :dynamic}."
@@ -228,7 +223,7 @@
228223
:arglists '([id & body] [{:keys [id level]} & body])}
229224
[s1 & body]
230225
(let [opts (if (map? s1) s1 {:id s1})
231-
level-form (get opts :level 5)
226+
level-form (get opts :level :info)
232227
id-form (get opts :id)
233228
location
234229
(enc/assoc-some nil
@@ -272,7 +267,7 @@
272267

273268
[opts & body]
274269
(impl/valid-opts! &form &env 'tufte/profiled opts body)
275-
(let [opts (merge {:level 5} opts)
270+
(let [opts (merge {:level :info} opts)
276271
ns-form* (get opts :ns :auto)
277272
ns-form (auto-> ns-form* (str *ns*))
278273

@@ -299,9 +294,9 @@
299294
(macroexpand '(profiled {:allow? false}))
300295

301296
(profiled {} (p :p1 nil))
302-
(profiled {} (p {:level 5 :id :p1} nil))
297+
(profiled {} (p {:level :info :id :p1} nil))
303298
(profiled {} (p (let [x :foo/id] x) "body"))
304-
(profiled {:level 2 :when (chance 0.5)} (p :p1 "body"))
299+
(profiled {:level :info :when (chance 0.5)} (p :p1 "body"))
305300
(profiled {} (p :foo (p :bar nil))))
306301

307302
#?(:clj
@@ -316,7 +311,7 @@
316311
(let [cljs? (boolean (:ns &env))
317312
clj? (not cljs?)
318313

319-
opts (merge {:level 5} opts)
314+
opts (merge {:level :info} opts)
320315
ns-form* (get opts :ns :auto)
321316
ns-form (auto-> ns-form* (str *ns*))
322317

@@ -801,8 +796,8 @@
801796
(p :10ms (Thread/sleep 10))
802797
"Result"))
803798

804-
(profile {:level 2 :id ::sleepy :data "foo"} (sleepy-threads))
805-
(profile {:level 2 :id ::sleepy :dynamic? true} (sleepy-threads))
799+
(profile {:level :info :id ::sleepy :data "foo"} (sleepy-threads))
800+
(profile {:level :info :id ::sleepy :dynamic? true} (sleepy-threads))
806801
(p :hello "Hello, this is a result") ; Falls through (no pdata context)
807802

808803
(defnp arithmetic []
@@ -819,7 +814,7 @@
819814
(profile {} (dotimes [n 1e5] (p :p1 nil)))
820815
(profile {} (dotimes [n 1e6] (p :p1 nil)))
821816
(profiled {} (dotimes [n 1e6] (p :p1 nil)))
822-
(profiled {:level 2 :when (chance 0.5)} "body")
817+
(profiled {:level :info :when (chance 0.5)} "body")
823818

824819
@(second (profiled {:nmax 10000 :dynamic? true} (dotimes [n 200] (p :p1 nil))))
825820

src/taoensso/tufte/impl.cljc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,10 @@
699699
:id-filter (or id-filter (get base :id-filter))
700700
:min-level (or min-level (get base :min-level))}))))
701701

702-
(let [base (enc/get-env {:as :edn} [:taoensso.tufte/rt-filters<.platform><.edn>])
703-
ns-filter (enc/get-env {:as :edn} [:taoensso.tufte/rt-ns-filter<.platform><.edn>])
704-
id-filter (enc/get-env {:as :edn} [:taoensso.tufte/rt-id-filter<.platform><.edn>])
705-
min-level (enc/get-env {:as :edn, :default 2} [:taoensso.tufte/rt-min-level<.platform><.edn>])]
702+
(let [base (enc/get-env {:as :edn} [:taoensso.tufte/rt-filters<.platform><.edn>])
703+
ns-filter (enc/get-env {:as :edn} [:taoensso.tufte/rt-ns-filter<.platform><.edn>])
704+
id-filter (enc/get-env {:as :edn} [:taoensso.tufte/rt-id-filter<.platform><.edn>])
705+
min-level (enc/get-env {:as :edn, :default :info} [:taoensso.tufte/rt-min-level<.platform><.edn>])]
706706

707707
(enc/defonce ^:dynamic *rt-call-filter*
708708
"`SpecFilter` used for runtime filtering, or nil."

0 commit comments

Comments
 (0)