BonyTrace

Print all messages sent or received by a process.

How to use

> BonyTrace.start(pid)

#PID<0.162.0> SENT TO: #PID<0.162.0>                   +0.000000s
MESSAGE: :hi
#PID<0.162.0> RECEIVED                                 +0.000003s
MESSAGE: :hi

> BonyTrace.stop(pid)

You can also set a :receiver function to get more info from the recerver's pid:

spawn(fn ->
  BonyTrace.start(self(), receiver: &Process.info(&1, :initial_call))
  send(self(), :hi)

  receive do
    _msg ->
      # keep alive 1s
      :timer.sleep(1000)
      :ok
  end
end)
#PID<0.205.0> SENT TO: #PID<0.205.0>                                  +0.000000s
MESSAGE: :hi
#PID<0.205.0> RECEIVED                                                +0.000003s
MESSAGE: :hi
#PID<0.207.0> SENT TO: {:initial_call, {:erlang, :apply, 2}}          +0.000000s
MESSAGE: :hi
#PID<0.207.0> RECEIVED                                                +0.000003s
MESSAGE: :hi

Installation

adding bony_trace to your list of dependencies in mix.exs:

def deps do
  [
    {:bony_trace, "~> 0.1.2", only: [:dev]}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/bony_trace.