<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I have made some wrappers around ttb and io_lib_pretty in the locks application.</div><div class=""><br class=""></div><div class="">The main purpose is to capture trace from complex multi-node tests, such as 5-node netsplit:</div><div class=""><a href="https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L75" class="">https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L75</a></div><div class=""><br class=""></div><div class="">If the test goes well, trace is discarded:</div><div class=""><a href="https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L115" class="">https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L115</a></div><div class=""><br class=""></div><div class="">If it fails, the trace logs are fetched:</div><div class=""><a href="https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L109" class="">https://github.com/uwiger/locks/blob/master/test/locks_leader_tests.erl#L109</a></div><div class=""><br class=""></div><div class="">The trace wrapper itself is in locks_ttb.erl:</div><div class=""><a href="https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L14" class="">https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L14</a></div><div class=""><br class=""></div><div class="">TTB uses pretty much the same API as dbg, but adds the ability to merge trace logs from different nodes.</div><div class=""><br class=""></div><div class="">To view a pretty-printed merged log, use locks_ttb:format/2</div><div class=""><a href="https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L38" class="">https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L38</a></div><div class=""><br class=""></div><div class="">The pretty-printed output starts with an emacs option header for erlang-mode.</div><div class=""><br class=""></div><div class="">To get records nicely formatted in the trace output, I export callback functions from relevant modules, e.g.</div><div class=""><a href="https://github.com/uwiger/locks/blob/master/src/locks_agent.erl#L122" class="">https://github.com/uwiger/locks/blob/master/src/locks_agent.erl#L122</a></div><div class=""><br class=""></div><div class="">This is used by locks_ttb:record_print_fun/1</div><div class=""><a href="https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L101" class="">https://github.com/uwiger/locks/blob/master/src/locks_ttb.erl#L101</a></div><div class=""><br class=""></div><div class="">Wading through reams of trace output is still boring, but at least much more accessible this way.</div><div class=""><br class=""></div><div class="">BR,</div><div class="">Ulf W</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 01 Jul 2015, at 16:58, Nick Marino <<a href="mailto:nmarino@basho.com" class="">nmarino@basho.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">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.</div><div class=""><br class=""></div><div class="">More info on how to use io_lib_pretty at these links:</div><div class=""><a href="http://amiest-devblog.blogspot.com/2008/05/iolibpretty-nice-secret-module.html" target="_blank" class="">http://amiest-devblog.blogspot.com/2008/05/iolibpretty-nice-secret-module.html</a></div><div class=""><a href="http://erlang.2086793.n4.nabble.com/Pretty-printing-records-td2110531.html" target="_blank" class="">http://erlang.2086793.n4.nabble.com/Pretty-printing-records-td2110531.html</a></div><div class=""><br class=""></div><div class="">Nick</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Jun 27, 2015 at 5:31 AM, Alex Shneyderman <span dir="ltr" class=""><<a href="mailto:a.shneyderman@gmail.com" target="_blank" class="">a.shneyderman@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, all!<br class="">
<br class="">
I would like to nicely format dbg output. I have a formatter function<br class="">
but io:format() out of there produces plain tuples. Even if I am<br class="">
running this dbg:tc() code within the shell that saw rr() call<br class="">
beforehand.<br class="">
<br class="">
Is there a lib some place that helps with formatting records nicely,<br class="">
besides trying to dig it out the shell code?<br class="">
<br class="">
Cheers,<br class="">
Alex.<br class="">
_______________________________________________<br class="">
erlang-questions mailing list<br class="">
<a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank" class="">http://erlang.org/mailman/listinfo/erlang-questions</a><br class="">
</blockquote></div><br class=""></div>
_______________________________________________<br class="">erlang-questions mailing list<br class=""><a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></blockquote></div><br class=""><div apple-content-edited="true" class="">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;"><div class=""><div class="">Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.</div><div class=""><a href="http://feuerlabs.com" class="">http://feuerlabs.com</a></div></div><div class=""><br class=""></div></span><br class="Apple-interchange-newline">
</div>
<br class=""></body></html>