Closed DjebbZ closed 6 years ago
The bug exists in both "0.1.3" and "0.1.4".
And I think I have a hint at why. I'm using a REPL with the usual REPL-friendly reloaded workflow, but I've just remember that multimethods aren't REPL-friendly like that. So I've dived a little bit in the code and found that in spy-emit
instead of calling the log-cs
multimethod it directly calls sc.api.logging/log-spy-ep-post-eval
or the version installed in the map. So registering a logger has no use here ?
Hi, long time no see IRL :)
Hi! Yeah, a Paris Meetup should be announced soon :)
I've tried registering globally a no-op function with (sc.api.logging/register-cs-logger :sc/spy-ep-post-eval-logger (fn [_])) but it didn't work.
Yes, it's a mistake of usage, I think there are several misunderstandings to address here:
sc.api.logging/register-cs-logger
, which is intended to define a 'Code Site' logger, which implements the notification sent when compiling a Code Site, at macro-expansion-time.(sc.api/spy {:sc/spy-ep-post-eval-logger (fn [_])} (my-code ...))
) or to define your own spy
macro with different defaults.The Customization section of the Tutorial shows an example of defining both a custom Code Site Logger and a custom Post Eval Logger.
In your case, defining a silent Post-Eval Logger would consist of something like:
(defn noop-spy-post-eval
[_ep-data])
(def my-spy-opts
;; mind the syntax-quote '`'
`{:sc/spy-ep-post-eval-logger noop-spy-post-eval})
(defmacro my-spy
([] (sc.api/spy-emit my-spy-opts nil &env &form))
([expr] (sc.api/spy-emit my-spy-opts expr &env &form))
([opts expr] (sc.api/spy-emit (merge my-spy-opts opts) expr &env &form)))
If you really wanted to change the configuration globally, you could use the following dark magic hack:
;; HACK changing the impl of the default Post Eval Logger via Var mutation
(alter-var-root #'sc.api.logging/log-spy-ep-post-eval
(constantly noop-spy-post-eval))
I would happily accept PRs that makes the doc clearer in this matter.
My bad, I didn't see the Tutorial at all. What I ended up doing is copy-paste the slient Post-Eval logger snippet in my profile.boot
and call (boot.user/my-spy (my-code ...))
. The only difference is that I had to remove the syntax quote, otherwise it was thinking that the fully qualified symbol was from clojure.core. Dark macro magic...
I'll think on a PR.
Alright, given that you didn't see the Tutorial I'll close this issue, but of course you are still welcome to open more specific issues or PRs regarding this topic.
Hi, long time no see IRL :)
I'm trying to slience the post-eval-logger because the data I want to inspect and play with is big, and logging it hides the Execution point haha.
I've tried registering globally a no-op function with
(sc.api.logging/register-cs-logger :sc/spy-ep-post-eval-logger (fn [_]))
but it didn't work. The only thing that worked was passing this function explicitly at call site ofspy
:(sc.api/spy {:sc/spy-ep-post-eval-logger (fn [_])} (my-code ...))
.Bug or mistake ? If it's a mistake, please correct me. In exchange you'll get a PR with documentation for this feature. Deal ?