tools.trace: trace-ns & untrace-ns function proposal

57 views
Skip to first unread message

Michał Marczyk

unread,
Feb 16, 2012, 4:12:31 PM2/16/12
to cloju...@googlegroups.com
Hi,

I'd like to offer two functions of mine for inclusion in tools.trace,
recently brought back into my working memory by a comment on this old
Gist of mine:

https://gist.github.com/492764

trace-ns causes calls to all functions in a given namespace to print
out tracing info; untrace-ns restores the original functions. Both
seem to work fine with Clojure 1.3 and the current tools.trace.

The patch is attached. (It's the same code + a test.) I though I'd
postpone creating a JIRA ticket until after soliciting comments -- let
me know if I should have gone ahead and created it right away, I'm not
too clear on the current preferred workflow... Also, I hope it's ok to
send patches directly to the list.

Sincerely,
Michał

0001-Add-trace-ns-and-untrace-ns.patch

Softaddicts

unread,
Feb 16, 2012, 6:22:12 PM2/16/12
to cloju...@googlegroups.com
Hi,

I looked at it and the code Don Jackson wrote.

I see value in this. Lets wait a week or so for comments and after I'll take
a shot at it and merge this to get another version out.

Has Don sent a CA ? I did not find his name in the list.


Luc P.

> > -- > You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
> To post to this group, send email to cloju...@googlegroups.com.
> To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
> > --
Softaddicts<lprefo...@softaddicts.ca> sent by ibisMail!

Michał Marczyk

unread,
Feb 16, 2012, 7:57:33 PM2/16/12
to cloju...@googlegroups.com
On 17 February 2012 00:22, Softaddicts <lprefo...@softaddicts.ca> wrote:
> I see value in this. Lets wait a week or so for comments and after I'll take
> a shot at it and merge this to get another version out.

Great!

> Has Don sent a CA ? I did not find his name in the list.

Wouldn't know, we could reach out to him on GitHub. I'll be replying
to his last comment on my Gist once I'm done with this message, so
I'll attach a link to this discussion and my new Gist (see below).

I have a new approach though which I like best ATM, mostly because of
how factored it came out to be -- one moderately complex function + a
bunch of one-liners of some utility. I need to read Don's code
properly to compare. Also, a switch to namespaced keywords would make
sense if this was to go into tools.trace... will do that later.

https://gist.github.com/1849273

If this seems interesting, I'll make the switch to namespaced
keywords, test this properly, try and take into accounts any comments,
maybe make a few tweaks and prepare a patch.

Sincerely,
Michał

Michał Marczyk

unread,
Feb 16, 2012, 8:23:09 PM2/16/12
to cloju...@googlegroups.com
On 17 February 2012 01:57, Michał Marczyk <michal....@gmail.com> wrote:
> Wouldn't know, we could reach out to him on GitHub. I'll be replying
> to his last comment on my Gist once I'm done with this message, so
> I'll attach a link to this discussion and my new Gist (see below).

Done.

> Also, a switch to namespaced keywords would make
> sense if this was to go into tools.trace... will do that later.

Done. Also fixed some bugs.

> If this seems interesting, I'll make the switch to namespaced
> keywords, test this properly, try and take into accounts any comments,
> maybe make a few tweaks and prepare a patch.

New patch attached.

Sincerely,
Michał

0001-Add-un-trace-var-vars-ns.patch

Michał Marczyk

unread,
Feb 16, 2012, 8:59:12 PM2/16/12
to cloju...@googlegroups.com
Hm, I somehow managed to remove the key function from the Gist in the
last update, fixed now. The patch is correct though.

Sincerely,
Michał

Michał Marczyk

unread,
Feb 16, 2012, 9:30:06 PM2/16/12
to cloju...@googlegroups.com
Here's a new patch to be applied on top of the old one making
trace-var use trace-fn-call for prettier output. The following is now
possible:

Clojure 1.3.0
user=> (ns trace-ns-test.core)
nil
trace-ns-test.core=> (defn foo [] :foo)
#'trace-ns-test.core/foo
trace-ns-test.core=> (defn bar [] (foo))
#'trace-ns-test.core/bar
trace-ns-test.core=> (in-ns 'user)
#<Namespace user>
user=> (use 'clojure.tools.trace)
nil
user=> (trace-ns 'trace-ns-test.core)
nil
user=> (trace-ns-test.core/bar)
TRACE t136: (trace-ns-test.core/bar)
TRACE t137: | (trace-ns-test.core/foo)
TRACE t137: | => :foo
TRACE t136: => :foo
:foo
user=> (untrace-ns 'trace-ns-test.core)
nil
user=> (trace-ns-test.core/bar)
:foo

All the best,
Michał

0002-Have-trace-var-use-trace-fn-call.patch

Michał Marczyk

unread,
Feb 16, 2012, 9:31:36 PM2/16/12
to cloju...@googlegroups.com
On 17 February 2012 03:30, Michał Marczyk <michal....@gmail.com> wrote:
> Here's a new patch to be applied on top of the old one making
> trace-var use trace-fn-call for prettier output.

s/old one/last one/

Softaddicts

unread,
Feb 16, 2012, 9:32:35 PM2/16/12
to cloju...@googlegroups.com
Fine, I'll look into it Sunday night.

Thank you
Luc

Stuart Sierra

unread,
Feb 17, 2012, 9:35:37 AM2/17/12
to cloju...@googlegroups.com
I'm happy too see people taking tools.trace forward from the casual implementation I started several years ago. Yay Clojure Community!

-S

Reply all
Reply to author
Forward
0 new messages