File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 31
31
[taoensso.truss :as truss]
32
32
[taoensso.encore :as enc]
33
33
[taoensso.encore.stats :as stats]
34
- [taoensso.tufte.impl :as impl #?@(:cljs [:refer [PStats]])])
34
+ [taoensso.tufte.impl :as impl #?@(:cljs [:refer [PStats HandlerVal ]])])
35
35
36
- #? (:clj (:import [taoensso.tufte.impl PStats]))
36
+ #? (:clj (:import [taoensso.tufte.impl PStats HandlerVal ]))
37
37
#? (:cljs (:require-macros [taoensso.tufte :refer [profiled]])))
38
38
39
39
(comment
469
469
(profiled {:level 2 :when (chance 0.5 )} (p :p1 " body" ))
470
470
(profiled {} (p :foo (p :bar ))))
471
471
472
- (defrecord HandlerVal [ns-str level ?id ?data pstats pstats-str_ ?file ?line])
473
-
474
472
#?(:clj
475
473
(defmacro profile
476
474
" Always executes body, and always returns <body-result>.
556
554
557
555
(comment (profile {:id ::my-id } (p :p1 " body" )))
558
556
559
- ; ;;; Output handlers
557
+ ; ;;; Handlers
560
558
; ; Handlers are used for `profile` output, let us nicely decouple stat
561
559
; ; creation and consumption.
562
560
Original file line number Diff line number Diff line change 638
638
(map (fn [id] (str id sep (format-pstats (get m id) format-pstats-opts))))
639
639
sorted-profiling-ids)))))
640
640
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 )))])
642
656
643
657
(enc/defonce handlers_ " {<hid> <handler-fn>}" (atom nil ))
644
658
You can’t perform that action at this time.
0 commit comments