I am trying to inspect the messages a node receives from other nodes, but in some other manner other than flush()
, because the message size is rather big and it doesn't help. Also, I can see the messages with erlang:process_info(self(), messages_queue_len).
, but I would like some way of extracting one message at a time in some kind of variable for debugging purposes.
You might want to have a look to the dbg
module in Erlang.
Start the tracer:
dbg:tracer().
Trace all messages received (r) by a process (in this case self()):
dbg:p(self(), r).
More information here.
or you can use:
1> F = fun() -> receive X -> {message, X} after 0 -> no_message end end.
#Fun<erl_eval.20.111823515>
2> F().
no_message
3> self() ! foo.
foo
4> self() ! bar.
bar
5> F().
{message, foo}
6> F().
{message, bar}
... to prevent blocking
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With