diff --git a/src/postmortem/core.cljc b/src/postmortem/core.cljc index 1194c3a..03248af 100644 --- a/src/postmortem/core.cljc +++ b/src/postmortem/core.cljc @@ -231,7 +231,6 @@ ([session key xform x] (spy> x session key xform))) (macros/deftime - (defmacro locals "Creates and returns a local environment map at the call site. A local environment map is a map of keyword representing each local name @@ -255,6 +254,13 @@ ([session key xform] `(spy> (locals) ~session ~key ~xform))) + (defmacro expr + "A simplified version of spy>>. Same as (spy>> ' )." + {:added "0.5.3"} + ([e] `(expr ~e identity)) + ([e xform] `(expr (current-session) ~e ~xform)) + ([session e xform] `(spy> ~e ~session '~e ~xform))) + ) (defn make-logger @@ -277,7 +283,7 @@ (defn make-multi-logger "Creates a multi logger. - + A multi logger is a variant of the simple logger. If called with two arguments, it acts like `(spy>> )` on the implicit session. If called with one argument, it acts like (log-for )`. diff --git a/test/postmortem/core_test.cljc b/test/postmortem/core_test.cljc index e827ea9..29e4443 100644 --- a/test/postmortem/core_test.cljc +++ b/test/postmortem/core_test.cljc @@ -87,6 +87,16 @@ (is (= {} (pm/logs))) (is (= {} (pm/stats)))) +(deftest ^:eftest/synchronized expr-test + (is (= 15 + (loop [i 5, sum 0] + (if (zero? i) + sum + (recur (dec i) (pm/expr (+ i sum))))))) + (is (= [5 9 12 14 15] + (pm/log-for '(+ i sum)))) + (pm/reset!)) + ;; Assert this function definition compiles ;; cf. https://github.com/athos/postmortem/issues/2 (defn regression-2 [^long x]