Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
This isn’t mentioned in the article, but I found debug-repl [1] to be debugging in the repl. For simple prints, wrapping expressions in (doto prn) has always been enough for me without custom readers. But when debugging something super odd, just stopping somewhere and evaluating a bunch of code (with locals in scope) to understand what you’re dealing with is invaluable. Clojure’s immutability makes it especially nice since you can just rerun (most) expressions to “see what happens.”
[1] https://github.com/gfredericks/debug-repl
The first example about spyscope is.. not good. The point of it is you can stick it in front of any form, not to use it with println debugging. For a better example, at https://github.com/dgrnbrg/spyscope#spyp
Assuming the crash doesn't cause the process to completely exit, you could indeed use `scope-capture` for this. This works well for local dev. In theory, you could use `sc.api/spy` in production code, and then attach a remote repl to diagnose any crashes. I wouldn't recommend this though, I think it would be best to use a good logging library like Mulog: https://github.com/BrunoBonacci/mulog
I asked something similar on the Cider Github and it sounds like it's not possible to get ELisp level debugging:
https://github.com/clojure-emacs/cider/discussions/2999
If anything Clojure needs this more than ELisp b/c of the crazy error stacks and b/c of how the laziness makes things blow up in all sorts of weird places