I've been working on a tracing library, that works much like
clojure.contrib.trace (based on it, actually). One sticky problem
I've found is, hierarchical logs are really crappy to try to stream to
a file. You can't just keep writing to the end of the file - new data
needs to be inserted before existing end-tags. So what I'm doing is
storing the data as a list, until I know the data is complete, and
then i turn it back into a tree to write the file.
However I can't think of a simple way to do it, even though it seems
like a simple operation.
I want to turn this list of pairs (first item is the fn call or return
value, the second is a truthy value marking whether it's a call or
return)
I toyed with some simple ways of doing this, but I don't think any of
them will actually work out. I think the advice you got in #clojure to
use zippers is probably correct. Here's a sketch I bashed out that
seems to do roughly what you want: https://gist.github.com/1807340 (I
took the liberty of wrapping the whole thing in another [] under the
assumption you'd want to record multiple top-level calls; if not you
can just call first on the result).
On Feb 11, 8:39 pm, jweiss <jeffrey.m.we...@gmail.com> wrote:
> I've been working on a tracing library, that works much like
> clojure.contrib.trace (based on it, actually). One sticky problem
> I've found is, hierarchical logs are really crappy to try to stream to
> a file. You can't just keep writing to the end of the file - new data
> needs to be inserted before existing end-tags. So what I'm doing is
> storing the data as a list, until I know the data is complete, and
> then i turn it back into a tree to write the file.
> However I can't think of a simple way to do it, even though it seems
> like a simple operation.
> I want to turn this list of pairs (first item is the fn call or return
> value, the second is a truthy value marking whether it's a call or
> return)
> I've been working on a tracing library, that works much like
> clojure.contrib.trace (based on it, actually). One sticky problem
> I've found is, hierarchical logs are really crappy to try to stream to
> a file. You can't just keep writing to the end of the file - new data
> needs to be inserted before existing end-tags. So what I'm doing is
> storing the data as a list, until I know the data is complete, and
> then i turn it back into a tree to write the file.
> However I can't think of a simple way to do it, even though it seems
> like a simple operation.
> I want to turn this list of pairs (first item is the fn call or return
> value, the second is a truthy value marking whether it's a call or
> return)
Thinking about it some more, I don't think I'm going to come up with a
solution that's any more efficient or easy to code as this one. The
real "work" is figuring out where the next element needs to be
inserted. Zipper keeps that information as part of the data structure
so it doesn't have to be re-calculated every iteration. My previous
solution using loop had kept an accumulator (a list of indices to pass
to assoc-in).
-jeff
On Feb 12, 3:42 am, Alan Malloy <a...@malloys.org> wrote:
> I toyed with some simple ways of doing this, but I don't think any of
> them will actually work out. I think the advice you got in #clojure to
> use zippers is probably correct. Here's a sketch I bashed out that
> seems to do roughly what you want:https://gist.github.com/1807340(I > took the liberty of wrapping the whole thing in another [] under the
> assumption you'd want to record multiple top-level calls; if not you
> can just call first on the result).
> On Feb 11, 8:39 pm, jweiss <jeffrey.m.we...@gmail.com> wrote:
> > I've been working on a tracing library, that works much like
> > clojure.contrib.trace (based on it, actually). One sticky problem
> > I've found is, hierarchical logs are really crappy to try to stream to
> > a file. You can't just keep writing to the end of the file - new data
> > needs to be inserted before existing end-tags. So what I'm doing is
> > storing the data as a list, until I know the data is complete, and
> > then i turn it back into a tree to write the file.
> > However I can't think of a simple way to do it, even though it seems
> > like a simple operation.
> > I want to turn this list of pairs (first item is the fn call or return
> > value, the second is a truthy value marking whether it's a call or
> > return)
Without even converting it into a tree. But I am having a hard time
finding an example of custom dispatch, or docs on how to write one. I
really just want things printed the same as pprint currently does, but
being able to specify extra indent for the whole block. I had
originally planned to output html where each item was properly nested
as html divs, but I think that is getting overly complex.
-jeff
On Feb 14, 10:14 am, jweiss <jeffrey.m.we...@gmail.com> wrote:
> Thinking about it some more, I don't think I'm going to come up with a
> solution that's any more efficient or easy to code as this one. The
> real "work" is figuring out where the next element needs to be
> inserted. Zipper keeps that information as part of the data structure
> so it doesn't have to be re-calculated every iteration. My previous
> solution using loop had kept an accumulator (a list of indices to pass
> to assoc-in).
> -jeff
> On Feb 12, 3:42 am, Alan Malloy <a...@malloys.org> wrote:
> > I toyed with some simple ways of doing this, but I don't think any of
> > them will actually work out. I think the advice you got in #clojure to
> > use zippers is probably correct. Here's a sketch I bashed out that
> > seems to do roughly what you want:https://gist.github.com/1807340(I > > took the liberty of wrapping the whole thing in another [] under the
> > assumption you'd want to record multiple top-level calls; if not you
> > can just call first on the result).
> > On Feb 11, 8:39 pm, jweiss <jeffrey.m.we...@gmail.com> wrote:
> > > I've been working on a tracing library, that works much like
> > > clojure.contrib.trace (based on it, actually). One sticky problem
> > > I've found is, hierarchical logs are really crappy to try to stream to
> > > a file. You can't just keep writing to the end of the file - new data
> > > needs to be inserted before existing end-tags. So what I'm doing is
> > > storing the data as a list, until I know the data is complete, and
> > > then i turn it back into a tree to write the file.
> > > However I can't think of a simple way to do it, even though it seems
> > > like a simple operation.
> > > I want to turn this list of pairs (first item is the fn call or return
> > > value, the second is a truthy value marking whether it's a call or
> > > return)
On Tue, Feb 14, 2012 at 6:33 PM, jweiss <jeffrey.m.we...@gmail.com> wrote: > It occurred to me that ultimately what I want is just a pretty-printed > output that I can put on a webpage and apply syntaxhighlighter to.
> I should be able to use a custom pprint dispatch to take this > [[(+ 5 (- 4 2 (* 9 3)) (* 5 (+ 6 3))) nil] > [(- 4 2 (* 9 3)) nil] > [(* 9 3) nil] > [27 true] > [-25 true] > [(* 5 (+ 6 3)) nil] > [(+ 6 3) nil] > [9 true] > [45 true] > [25 true]]
> Without even converting it into a tree. But I am having a hard time > finding an example of custom dispatch, or docs on how to write one. I > really just want things printed the same as pprint currently does, but > being able to specify extra indent for the whole block. I had > originally planned to output html where each item was properly nested > as html divs, but I think that is getting overly complex.
> -jeff
> On Feb 14, 10:14 am, jweiss <jeffrey.m.we...@gmail.com> wrote: >> Thanks, Alan,
>> Thinking about it some more, I don't think I'm going to come up with a >> solution that's any more efficient or easy to code as this one. The >> real "work" is figuring out where the next element needs to be >> inserted. Zipper keeps that information as part of the data structure >> so it doesn't have to be re-calculated every iteration. My previous >> solution using loop had kept an accumulator (a list of indices to pass >> to assoc-in).
>> -jeff
>> On Feb 12, 3:42 am, Alan Malloy <a...@malloys.org> wrote:
>> > I toyed with some simple ways of doing this, but I don't think any of >> > them will actually work out. I think the advice you got in #clojure to >> > use zippers is probably correct. Here's a sketch I bashed out that >> > seems to do roughly what you want:https://gist.github.com/1807340(I >> > took the liberty of wrapping the whole thing in another [] under the >> > assumption you'd want to record multiple top-level calls; if not you >> > can just call first on the result).
>> > On Feb 11, 8:39 pm, jweiss <jeffrey.m.we...@gmail.com> wrote:
>> > > I've been working on a tracing library, that works much like >> > > clojure.contrib.trace (based on it, actually). One sticky problem >> > > I've found is, hierarchical logs are really crappy to try to stream to >> > > a file. You can't just keep writing to the end of the file - new data >> > > needs to be inserted before existing end-tags. So what I'm doing is >> > > storing the data as a list, until I know the data is complete, and >> > > then i turn it back into a tree to write the file.
>> > > However I can't think of a simple way to do it, even though it seems >> > > like a simple operation.
>> > > I want to turn this list of pairs (first item is the fn call or return >> > > value, the second is a truthy value marking whether it's a call or >> > > return)
>> > > I want to turn that into >> > > [(+ 1 (- 5 2)) >> > > [(- 5 2) >> > > 3] >> > > 4]
>> > > Is there a simple way to do this?
> -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your first post. > To unsubscribe from this group, send email to > clojure+unsubscribe@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en
-- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things?
Wish I could find an example of those being used in a custom dispatch,
I made a lame attempt and for some reason my custom dispatch printed
nothing at all :) I can dig in and figure it out, but it would be
quicker if someone has already been there. Surely someone has done
this :)
-jeff
On Feb 15, 3:02 am, Kevin Downey <redc...@gmail.com> wrote:
> On Tue, Feb 14, 2012 at 6:33 PM, jweiss <jeffrey.m.we...@gmail.com> wrote:
> > It occurred to me that ultimately what I want is just a pretty-printed
> > output that I can put on a webpage and apply syntaxhighlighter to.
> > I should be able to use a custom pprint dispatch to take this
> > [[(+ 5 (- 4 2 (* 9 3)) (* 5 (+ 6 3))) nil]
> > [(- 4 2 (* 9 3)) nil]
> > [(* 9 3) nil]
> > [27 true]
> > [-25 true]
> > [(* 5 (+ 6 3)) nil]
> > [(+ 6 3) nil]
> > [9 true]
> > [45 true]
> > [25 true]]
> > Without even converting it into a tree. But I am having a hard time
> > finding an example of custom dispatch, or docs on how to write one. I
> > really just want things printed the same as pprint currently does, but
> > being able to specify extra indent for the whole block. I had
> > originally planned to output html where each item was properly nested
> > as html divs, but I think that is getting overly complex.
> > -jeff
> > On Feb 14, 10:14 am, jweiss <jeffrey.m.we...@gmail.com> wrote:
> >> Thanks, Alan,
> >> The solution I used looks exactly like yours:
> >> Thinking about it some more, I don't think I'm going to come up with a
> >> solution that's any more efficient or easy to code as this one. The
> >> real "work" is figuring out where the next element needs to be
> >> inserted. Zipper keeps that information as part of the data structure
> >> so it doesn't have to be re-calculated every iteration. My previous
> >> solution using loop had kept an accumulator (a list of indices to pass
> >> to assoc-in).
> >> -jeff
> >> On Feb 12, 3:42 am, Alan Malloy <a...@malloys.org> wrote:
> >> > I toyed with some simple ways of doing this, but I don't think any of
> >> > them will actually work out. I think the advice you got in #clojure to
> >> > use zippers is probably correct. Here's a sketch I bashed out that
> >> > seems to do roughly what you want:https://gist.github.com/1807340(I > >> > took the liberty of wrapping the whole thing in another [] under the
> >> > assumption you'd want to record multiple top-level calls; if not you
> >> > can just call first on the result).
> >> > On Feb 11, 8:39 pm, jweiss <jeffrey.m.we...@gmail.com> wrote:
> >> > > I've been working on a tracing library, that works much like
> >> > > clojure.contrib.trace (based on it, actually). One sticky problem
> >> > > I've found is, hierarchical logs are really crappy to try to stream to
> >> > > a file. You can't just keep writing to the end of the file - new data
> >> > > needs to be inserted before existing end-tags. So what I'm doing is
> >> > > storing the data as a list, until I know the data is complete, and
> >> > > then i turn it back into a tree to write the file.
> >> > > However I can't think of a simple way to do it, even though it seems
> >> > > like a simple operation.
> >> > > I want to turn this list of pairs (first item is the fn call or return
> >> > > value, the second is a truthy value marking whether it's a call or
> >> > > return)
> >> > > I want to turn that into
> >> > > [(+ 1 (- 5 2))
> >> > > [(- 5 2)
> >> > > 3]
> >> > > 4]
> >> > > Is there a simple way to do this?
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
> --
> And what is good, Phaedrus,
> And what is not good—
> Need we ask anyone to tell us these things?