Skip to content

Commit c5f4fbb

Browse files
committed
[nop] Move HandlerVal to impln ns
1 parent e91352d commit c5f4fbb

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/taoensso/tufte.cljc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
[taoensso.truss :as truss]
3232
[taoensso.encore :as enc]
3333
[taoensso.encore.stats :as stats]
34-
[taoensso.tufte.impl :as impl #?@(:cljs [:refer [PStats]])])
34+
[taoensso.tufte.impl :as impl #?@(:cljs [:refer [PStats HandlerVal]])])
3535

36-
#?(:clj (:import [taoensso.tufte.impl PStats]))
36+
#?(:clj (:import [taoensso.tufte.impl PStats HandlerVal]))
3737
#?(:cljs (:require-macros [taoensso.tufte :refer [profiled]])))
3838

3939
(comment
@@ -469,8 +469,6 @@
469469
(profiled {:level 2 :when (chance 0.5)} (p :p1 "body"))
470470
(profiled {} (p :foo (p :bar))))
471471

472-
(defrecord HandlerVal [ns-str level ?id ?data pstats pstats-str_ ?file ?line])
473-
474472
#?(:clj
475473
(defmacro profile
476474
"Always executes body, and always returns <body-result>.
@@ -556,7 +554,7 @@
556554

557555
(comment (profile {:id ::my-id} (p :p1 "body")))
558556

559-
;;;; Output handlers
557+
;;;; Handlers
560558
;; Handlers are used for `profile` output, let us nicely decouple stat
561559
;; creation and consumption.
562560

src/taoensso/tufte/impl.cljc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,21 @@
638638
(map (fn [id] (str id sep (format-pstats (get m id) format-pstats-opts))))
639639
sorted-profiling-ids)))))
640640

641-
;;;; Output handlers
641+
;;;; Handlers
642+
643+
(defrecord HandlerVal [ns-str level ?id ?data pstats pstats-str_ ?file ?line]
644+
Object (toString [this] (str "taoensso.tufte.HandlerVal" (enc/pr-edn* (into {} this)))))
645+
646+
;; Verbose constructors for readability + to support extra keys
647+
(do (enc/def-print-impl [x HandlerVal] (str "#taoensso.tufte.HandlerVal" (enc/pr-edn* (into {} x)))))
648+
#?(:clj (enc/def-print-dup [x HandlerVal] (str "#taoensso.tufte.impl.HandlerVal" (enc/pr-edn* (into {} x)))))
649+
650+
(comment
651+
[(read-string (binding [*print-dup* true] (pr-str (HandlerVal. 0 0 0 0 0 0 0 0))))
652+
(read-string (binding [*print-dup* true] (pr-str (assoc (HandlerVal. 0 0 0 0 0 0 0 0) :k :v))))
653+
(do (binding [*print-dup* true] ( str (assoc (HandlerVal. 0 0 0 0 0 0 0 0) :k :v))))
654+
(do (pr-str (assoc (HandlerVal. 0 0 0 0 0 0 0 0) :k :v)))
655+
(do ( str (assoc (HandlerVal. 0 0 0 0 0 0 0 0) :k :v)))])
642656

643657
(enc/defonce handlers_ "{<hid> <handler-fn>}" (atom nil))
644658

0 commit comments

Comments
 (0)