Skip to content

Instantly share code, notes, and snippets.

@ivalentinee
Created June 27, 2018 18:09
Show Gist options
  • Select an option

  • Save ivalentinee/b87533e918fc393becadfe7923686017 to your computer and use it in GitHub Desktop.

Select an option

Save ivalentinee/b87533e918fc393becadfe7923686017 to your computer and use it in GitHub Desktop.
print_trace = fn(print_trace, fd) ->
receive do
msg ->
:io.format(fd, "call: (tracer pid: ~p)~n ~p~n", [self(), msg])
print_trace.(print_trace, fd)
end
end
{ok, fd} = :file.open("/tmp/trace.out", [:write])
custom_tracer = :proc_lib.spawn(fn -> print_trace.(print_trace, fd) end)
:erlang.trace(self(), true, [:all, {:tracer, custom_tracer}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment