Last active
December 16, 2019 16:44
-
-
Save mrzor/7aab0b628d73d7d2d87e0dfb02030e99 to your computer and use it in GitHub Desktop.
Prettify clojure.tools.trace/trace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; See https://greglook.github.io/puget/api/puget.printer.html | |
;; Hack tools trace to be prettier | |
;; (won't work if everything has been aot compiled with direct linking) | |
;; ty alexdmiller | |
(defn hacked-tracer [name value] | |
(println (str "TRACE" (when name (str " " name)) ": ") | |
;; you may want to remove the second param and bind puget.printer/*options* instead | |
(puget.printer/pprint-str value {:print-color true})) | |
value) | |
(defn hacked-trace | |
([value] (trace nil value)) | |
([name value] (hacked-tracer name value))) | |
(alter-var-root #'clojure.tools.trace/trace (fn [_] hacked-trace)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment