philoskim / debux

A trace-based debugging library for Clojure and ClojureScript.
468 stars 19 forks source link

Feature request: use custom object printer #27

Closed aneilbaboo closed 2 years ago

aneilbaboo commented 2 years ago

First, thank you for this wonderful library. I use it constantly.

I have some records for which I've defined custom printing functions, and I'd like to be able to see this version in my debux output. I'd like the ability to prevent certain objects from being turned into maps by the debux printer.

I should add that I'd like this to work even when the objects are nested inside other objects. I tried the :print option, and while I think I could eventually get that to work, it would require a tree traversal to find all of the objects I want to print using my custom printer.

aneilbaboo commented 2 years ago

I now realize that debux is just using pprint. I solved my problem by adding a method to simple-dispatch.


(defn my-foo-printer [o] (str "(->Foo " (:contents foo) ")"))

(defmethod print-method Foo
  [o w]
  (print-simple (my-foo-printer o) w))

(defmethod clojure.pprint/simple-dispatch Foo [o] (pr o))