clojure: adding a debug trace to every function in a namespace? -
Logging into one of my houses was started and I was just using mouse and cut-end- Paste it into each function in a larger module (trace (str "entering:" function-name))
The reason was caught and said, "Just got a better way" ... Can I think of creating a macro which wraps up an entire block of function and adds marks or something like that? Any advice from a wise pile - overflow - Closerian?
No need of a macro:
(defn trace-ns "Ns should be a namespace object or symbol." [Ns] (dosak [s (ns-interns ns)): let [v (ns-ns-nss)]: when (and (ifn? @ V) ( - & gt; V meta: not a macro)) (Internet with NetA (Meta S: Trusted Truth: Unrated, @ V)) (Let [F @ V] (FN [& amp; Egags] (Closer Contib. Toss / (trace): () () () () () (dsk (ns-interne ns) ns s]]: when (: find out (Meta V))] (change-meta! (Trainee ns s (untraced (meta v)) # (dissoc%: traced: untraced)))
... Or something like that. The most extra requirement will be to use filter
, so that there are no calls to things that are not ifn?
s Update: Edit in a solution on it (also macros management) Update 2: Fixed some major bugs Update 4: Enhanced unused functionality.
Update 3: my ripe here An example of L:
Users & gt; (Ns fu) neil foo & gt; (Defn foo [x] x) # 'foo / foo foot & gt; (Defmacro bar [x] x) # 'foo / bar foo & gt; (Ns user) zero user & gt; (Trace-ns' foo) zero user & gt; (Foo / foo: foo) Trace: "Log in: foo": foo user & gt; (AF / Bar: AFU): FUUI & gt; (Untrace-ns' foo) zero user & gt; (Foo / foo: foo): foo
Comments
Post a Comment