Skip to content

Commit

Permalink
Change log level unexpected info in client (#2422)
Browse files Browse the repository at this point in the history
Change log level for unexpected info in client and rejust code format in emqx_bridge
  • Loading branch information
Gilbert committed Apr 11, 2019
1 parent 6a4c318 commit 4fc81ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/emqx_bridge.erl
Expand Up @@ -323,10 +323,9 @@ connecting(enter, _, #{reconnect_delay_ms := Timeout,
{ok, ConnRef, Conn} ->
?LOG(info, "[Bridge] Bridge ~p connected", [name()]),
Action = {state_timeout, 0, connected},
{keep_state,
eval_bridge_handler(State#{ conn_ref => ConnRef
, connection => Conn}, connected),
Action};
State0 = State#{conn_ref => ConnRef, connection => Conn},
State1 = eval_bridge_handler(State0, connected),
{keep_state, State1, Action};
error ->
Action = {state_timeout, Timeout, reconnect},
{keep_state_and_data, Action}
Expand Down Expand Up @@ -424,7 +423,7 @@ common(StateName, Type, Content, State) ->
eval_bridge_handler(State = #{bridge_handler := ?NO_BRIDGE_HANDLER}, _Msg) ->
State;
eval_bridge_handler(State = #{bridge_handler := Handler}, Msg) ->
_ = Handler(Msg),
Handler(Msg),
State.

ensure_present(Key, Topic, State) ->
Expand Down Expand Up @@ -564,9 +563,8 @@ disconnect(#{connection := Conn,
connect_module := Module
} = State) when Conn =/= undefined ->
ok = Module:stop(ConnRef, Conn),
eval_bridge_handler(State#{conn_ref => undefined,
connection => undefined},
disconnected);
State0 = State#{conn_ref => undefined, connection => undefined},
eval_bridge_handler(State0, disconnected);
disconnect(State) ->
eval_bridge_handler(State, disconnected).

Expand Down
5 changes: 5 additions & 0 deletions src/emqx_client.erl
Expand Up @@ -928,6 +928,11 @@ handle_event(info, {inet_reply, _Sock, {error, Reason}}, _, State) ->
?LOG(error, "[Client] Got tcp error: ~p", [Reason]),
{stop, {shutdown, Reason}, State};

handle_event(info, EventContent = {'EXIT', _Pid, normal}, StateName, _State) ->
?LOG(error, "[Client] State: ~s, Unexpected Event: (info, ~p)",
[StateName, EventContent]),
keep_state_and_data;

handle_event(EventType, EventContent, StateName, _StateData) ->
?LOG(error, "[Client] State: ~s, Unexpected Event: (~p, ~p)",
[StateName, EventType, EventContent]),
Expand Down

0 comments on commit 4fc81ce

Please sign in to comment.