Skip to content

Instantly share code, notes, and snippets.

@mrzor
Last active December 16, 2019 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrzor/7aab0b628d73d7d2d87e0dfb02030e99 to your computer and use it in GitHub Desktop.
Save mrzor/7aab0b628d73d7d2d87e0dfb02030e99 to your computer and use it in GitHub Desktop.
Prettify clojure.tools.trace/trace
;; 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