繁体   English   中英

Elixir/Erlang - 跟踪邮件何时到达邮箱

[英]Elixir/Erlang - Trace when a message arrives in the mailbox

相当直接的问题,是否可以跟踪到达Process / GenServer (邮箱)的消息? 要知道可以在处理消息后立即跟踪消息(从邮箱中取出),但我似乎无法找到一种方法来挂钩消息的实际到达。

在 erlang 中,您在dbg:p/2中有标志, s用于发送, r用于接收:

1> dbg:tracer().
{ok,<0.82.0>}
2> dbg:p(self(), r).
(<0.80.0>) << {dbg,{ok,[{matched,nonode@nohost,1}]}}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.183997>,319}
{ok,[{matched,nonode@nohost,1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184000>,
                        [{expand_fun,#Fun<group.0.82824323>},
                         {echo,true},
                         {binary,false},
                         {encoding,latin1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184002>,ok}
3> self() ! trace_me.
(<0.80.0>) << {shell_cmd,<0.73.0>,
                         {eval,[{op,{1,8},
                                    '!',
                                    {call,{1,1},{atom,{1,1},self},[]},
                                    {atom,{1,10},trace_me}}]},
                         cmd}
(<0.80.0>) << trace_me
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184006>,319}
trace_me
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184008>,
                        [{expand_fun,#Fun<group.0.82824323>},
                         {echo,true},
                         {binary,false},
                         {encoding,latin1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184011>,ok}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM