fix(emqx_os_mon): log info level for unexpected message
also reply error for unexpected gen_server call and refine log message for unexpected gen_server cast
This commit is contained in:
parent
a6b95afda8
commit
d628d37a93
|
@ -85,11 +85,10 @@ init([]) ->
|
|||
{ok, #{}}.
|
||||
|
||||
handle_call(Req, _From, State) ->
|
||||
?LOG(error, "Unexpected call: ~p", [Req]),
|
||||
{reply, ignored, State}.
|
||||
{reply, {error, {unexpected_call, Req}}, State}.
|
||||
|
||||
handle_cast(Msg, State) ->
|
||||
?LOG(error, "Unexpected cast: ~p", [Msg]),
|
||||
?LOG(error, "unexpected_cast_discarded: ~p", [Msg]),
|
||||
{noreply, State}.
|
||||
|
||||
handle_info({timeout, _Timer, check}, State) ->
|
||||
|
@ -111,7 +110,7 @@ handle_info({timeout, _Timer, check}, State) ->
|
|||
{noreply, State};
|
||||
|
||||
handle_info(Info, State) ->
|
||||
?LOG(error, "unexpected info: ~p", [Info]),
|
||||
?LOG(info, "unexpected_info_discarded: ~p", [Info]),
|
||||
{noreply, State}.
|
||||
|
||||
terminate(_Reason, _State) ->
|
||||
|
|
|
@ -52,7 +52,8 @@ t_api(_) ->
|
|||
?assertEqual(ok, emqx_os_mon:set_procmem_high_watermark(0.11)),
|
||||
?assertEqual(11, emqx_os_mon:get_procmem_high_watermark()),
|
||||
|
||||
?assertEqual(ignored, gen_server:call(emqx_os_mon, ignored)),
|
||||
?assertEqual({error, {unexpected_call, ignored}},
|
||||
gen_server:call(emqx_os_mon, ignored)),
|
||||
?assertEqual(ok, gen_server:cast(emqx_os_mon, ignored)),
|
||||
emqx_os_mon ! ignored,
|
||||
gen_server:stop(emqx_os_mon),
|
||||
|
|
Loading…
Reference in New Issue