This strikes me as a handy debugging pattern:
(defonce dbg-db (atom {}))
(defn log [k v]
(swap! dbg-db update-in [k] conj v)
(js/console.log k v)
v)
You can sprinkle log statements in your code to check values (basically js/console.log but returns the value).
The 'innovation' is you can go back and play with the data after execution. Just pop the key you used when logging.
If you turned log
into a macro you should be able to capture more context:
- local vars via
&env
- file, line, column info from
&form
Extrapolating further, if s/instrument
evolved into a general use technique for hooking into execution then it might be useful for things like breakpoints, stack traces etc.