A simple tracer with recording capabilities that would help you in a live debugging session.
To use SmartTracer, update the mix.exs
to include it on your dependencies.
def deps do
[
{:smart_tracer, "~> 0.2.0"}
]
end
Documentation can be viewed here: https://hexdocs.pm/smart_tracer.
When connected to a live remote console, issue the trace/2
passing the function reference and rate limit.
iex> SmartTracer.trace(&FakeModule.hello/1, 5)
1
iex> FakeModule.hello("Vince")
Elixir.SmartTracer.Support.FakeModule.hello/1 is being called with:
["Vince"]
iex> SmartTracer.trace(&FakeModule.get_name/1, 5, scope: :local)
1
iex> FakeModule.hello("Vince")
Elixir.SmartTracer.Support.FakeModule.get_name/1 is being called with:
["Vince"]
iex> SmartTracer.trace(&FakeModulne.hello/1, 5, return: true)
1
iex> FakeModule.hello("Vince")
Elixir.SmartTracer.Support.FakeModule.hello/1 is being called with:
["Vince"]
Elixir.SmartTracer.Support.FakeModule.hello/1 returns:
"Hello, my name is NAME-Vince"
iex> SmartTracer.trace(&FakeModulne.hello/1, 5, return: true, record: true)
1
To playback all the recordings, use playback/0
iex> SmartTracer.playback()
[%SmartTracer.Utils.Recorder.Call{
args: ["Vince"],
arity: 1,
datetime: #DateTime<2020-02-01 18:13:04Z>,
function: :hello,
module: SmartTracer.Support.FakeModule,
type: :call
},
%SmartTracer.Utils.Recorder.Return{
arity: 1,
datetime: #DateTime<2020-02-01 18:13:04Z>,
function: :hello,
module: SmartTracer.Support.FakeModule,
return_value: "Hello, my name is NAME-Vince",
type: :return
}]