I'm trying to log all calls to a function with dbg
for debugging (thanks to this answer). Here's the code:
-module(a).
-export([main/0]).
trace_me(_, _, _) ->
ok.
main() ->
dbg:start(),
dbg:tracer(),
dbg:tpl(a, trace_me, 3, []),
dbg:p(all, c),
LargeBinary = binary:copy(<<"foo">>, 10000),
trace_me(foo, bar, LargeBinary).
The problem is that one of the argument is a really large binary, and the code above prints the complete binary with every call:
1> c(a).
{ok,a}
2> a:main().
(<0.57.0>) call a:trace_me(foo,bar,<<"foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo...lots of foos omitted...">>)
ok
Is it possible to (without modifying trace_me/3
):
Only print the the first 2 arguments for each call?
Print the first 2 arguments + first few bytes of the 3rd argument or just pass the 3rd argument through a custom function before printing?