[erlang-questions] is there rr() finctionality outside of shell?
Ulf Wiger
ulf@REDACTED
Thu Jul 2 11:05:57 CEST 2015
I have made some wrappers around ttb and io_lib_pretty in the locks application.
The main purpose is to capture trace from complex multi-node tests, such as 5-node netsplit:
https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L75 <https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L75>
If the test goes well, trace is discarded:
https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L115 <https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L115>
If it fails, the trace logs are fetched:
https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L109 <https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L109>
The trace wrapper itself is in locks_ttb.erl:
https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L14 <https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L14>
TTB uses pretty much the same API as dbg, but adds the ability to merge trace logs from different nodes.
To view a pretty-printed merged log, use locks_ttb:format/2
https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L38 <https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L38>
The pretty-printed output starts with an emacs option header for erlang-mode.
To get records nicely formatted in the trace output, I export callback functions from relevant modules, e.g.
https://github.com/uwiger/locks/blob/master/src/locks_agent.erl#L122 <https://github.com/uwiger/locks/blob/master/src/locks_agent.erl#L122>
This is used by locks_ttb:record_print_fun/1
https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L101 <https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L101>
Wading through reams of trace output is still boring, but at least much more accessible this way.
BR,
Ulf W
> On 01 Jul 2015, at 16:58, Nick Marino <nmarino@REDACTED> wrote:
>
> The shell uses the io_lib_pretty module to format records, so you could try tapping into that. It's undocumented, so YMMV, stuff could break in future versions, etc. But if you're careful with upgrades and such then you'll probably be okay.
>
> More info on how to use io_lib_pretty at these links:
> http://amiest-devblog.blogspot.com/2008/05/iolibpretty-nice-secret-module.html <http://amiest-devblog.blogspot.com/2008/05/iolibpretty-nice-secret-module.html>
> http://erlang.2086793.n4.nabble.com/Pretty-printing-records-td2110531.html <http://erlang.2086793.n4.nabble.com/Pretty-printing-records-td2110531.html>
>
> Nick
>
> On Sat, Jun 27, 2015 at 5:31 AM, Alex Shneyderman <a.shneyderman@REDACTED <mailto:a.shneyderman@REDACTED>> wrote:
> Hi, all!
>
> I would like to nicely format dbg output. I have a formatter function
> but io:format() out of there produces plain tuples. Even if I am
> running this dbg:tc() code within the shell that saw rr() call
> beforehand.
>
> Is there a lib some place that helps with formatting records nicely,
> besides trying to dig it out the shell code?
>
> Cheers,
> Alex.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150702/c4ee9223/attachment.htm>
More information about the erlang-questions
mailing list