critical -> error

This commit is contained in:
Feng Lee 2015-10-10 13:36:06 +08:00
parent fa84a2595b
commit f57e6b43db
7 changed files with 17 additions and 17 deletions

View File

@ -110,7 +110,7 @@ handle_call(kick, _From, State) ->
{stop, {shutdown, kick}, ok, State}; {stop, {shutdown, kick}, ok, State};
handle_call(Req, _From, State = #state{peername = Peername}) -> handle_call(Req, _From, State = #state{peername = Peername}) ->
lager:critical("Client ~s: unexpected request - ~p", [emqttd_net:format(Peername), Req]), lager:error("Client ~s: unexpected request - ~p", [emqttd_net:format(Peername), Req]),
{reply, {error, unsupported_request}, State}. {reply, {error, unsupported_request}, State}.
handle_cast({subscribe, TopicTable}, State) -> handle_cast({subscribe, TopicTable}, State) ->
@ -120,7 +120,7 @@ handle_cast({unsubscribe, Topics}, State) ->
with_session(fun(SessPid) -> emqttd_session:unsubscribe(SessPid, Topics) end, State); with_session(fun(SessPid) -> emqttd_session:unsubscribe(SessPid, Topics) end, State);
handle_cast(Msg, State = #state{peername = Peername}) -> handle_cast(Msg, State = #state{peername = Peername}) ->
lager:critical("Client ~s: unexpected msg - ~p",[emqttd_net:format(Peername), Msg]), lager:error("Client ~s: unexpected msg - ~p",[emqttd_net:format(Peername), Msg]),
{noreply, State}. {noreply, State}.
handle_info(timeout, State) -> handle_info(timeout, State) ->
@ -152,7 +152,7 @@ handle_info({inet_async, _Sock, _Ref, {error, Reason}}, State) ->
network_error(Reason, State); network_error(Reason, State);
handle_info({inet_reply, _Sock, {error, Reason}}, State = #state{peername = Peername}) -> handle_info({inet_reply, _Sock, {error, Reason}}, State = #state{peername = Peername}) ->
lager:critical("Client ~s: unexpected inet_reply '~p'", [emqttd_net:format(Peername), Reason]), lager:error("Client ~s: unexpected inet_reply '~p'", [emqttd_net:format(Peername), Reason]),
{noreply, State}; {noreply, State};
handle_info({keepalive, start, TimeoutSec}, State = #state{transport = Transport, socket = Socket, peername = Peername}) -> handle_info({keepalive, start, TimeoutSec}, State = #state{transport = Transport, socket = Socket, peername = Peername}) ->
@ -180,7 +180,7 @@ handle_info({keepalive, check}, State = #state{peername = Peername, keepalive =
end; end;
handle_info(Info, State = #state{peername = Peername}) -> handle_info(Info, State = #state{peername = Peername}) ->
lager:critical("Client ~s: unexpected info ~p",[emqttd_net:format(Peername), Info]), lager:error("Client ~s: unexpected info ~p",[emqttd_net:format(Peername), Info]),
{noreply, State}. {noreply, State}.
terminate(Reason, #state{peername = Peername, terminate(Reason, #state{peername = Peername,

View File

@ -129,11 +129,11 @@ handle_cast({unregister, ClientId, Pid}, State) ->
{noreply, setstats(State)}; {noreply, setstats(State)};
handle_cast(Msg, State) -> handle_cast(Msg, State) ->
lager:critical("Unexpected Msg: ~p", [Msg]), lager:error("Unexpected Msg: ~p", [Msg]),
{noreply, State}. {noreply, State}.
handle_info(Info, State) -> handle_info(Info, State) ->
lager:critical("Unexpected Msg: ~p", [Info]), lager:error("Unexpected Msg: ~p", [Info]),
{noreply, State}. {noreply, State}.
terminate(_Reason, #state{id = Id}) -> terminate(_Reason, #state{id = Id}) ->

View File

@ -385,7 +385,7 @@ handle_info({'DOWN', _Mon, _Type, DownPid, _Info}, State = #state{submap = SubMa
end; end;
handle_info(Info, State) -> handle_info(Info, State) ->
lager:critical("Unexpected Info: ~p", [Info]), lager:error("Unexpected Info: ~p", [Info]),
{noreply, State}. {noreply, State}.
terminate(_Reason, _State) -> terminate(_Reason, _State) ->

View File

@ -162,7 +162,7 @@ handle_call(_Request, _From, State) ->
{reply, ok, State}. {reply, ok, State}.
handle_cast(Msg, State) -> handle_cast(Msg, State) ->
lager:critical("Unexpected Msg: ~p", [Msg]), lager:error("Unexpected Msg: ~p", [Msg]),
{noreply, State}. {noreply, State}.
handle_info(stats, State = #state{stats_fun = StatsFun}) -> handle_info(stats, State = #state{stats_fun = StatsFun}) ->
@ -174,7 +174,7 @@ handle_info(expire, State = #state{expired_after = ExpiredAfter}) ->
{noreply, State, hibernate}; {noreply, State, hibernate};
handle_info(Info, State) -> handle_info(Info, State) ->
lager:critical("Unexpected Info: ~p", [Info]), lager:error("Unexpected Info: ~p", [Info]),
{noreply, State}. {noreply, State}.
terminate(_Reason, _State = #state{stats_timer = TRef1, expire_timer = TRef2}) -> terminate(_Reason, _State = #state{stats_timer = TRef1, expire_timer = TRef2}) ->

View File

@ -293,7 +293,7 @@ handle_call({publish, Msg = #mqtt_message{qos = ?QOS_2, pktid = PktId}}, _From,
end; end;
handle_call(Req, _From, State) -> handle_call(Req, _From, State) ->
lager:critical("Unexpected Request: ~p", [Req]), lager:error("Unexpected Request: ~p", [Req]),
{reply, ok, State}. {reply, ok, State}.
handle_cast({subscribe, TopicTable0, Callback}, Session = #session{ handle_cast({subscribe, TopicTable0, Callback}, Session = #session{
@ -469,7 +469,7 @@ handle_cast({pubcomp, PktId}, Session = #session{client_id = ClientId, awaiting_
end; end;
handle_cast(Msg, State) -> handle_cast(Msg, State) ->
lager:critical("Unexpected Msg: ~p, State: ~p", [Msg, State]), lager:error("Unexpected Msg: ~p, State: ~p", [Msg, State]),
{noreply, State}. {noreply, State}.
%% Queue messages when client is offline %% Queue messages when client is offline
@ -570,7 +570,7 @@ handle_info(session_expired, Session = #session{client_id = ClientId}) ->
{stop, {shutdown, expired}, Session}; {stop, {shutdown, expired}, Session};
handle_info(Info, Session = #session{client_id = ClientId}) -> handle_info(Info, Session = #session{client_id = ClientId}) ->
lager:critical("Session(~s) unexpected info: ~p", [ClientId, Info]), lager:error("Session(~s) unexpected info: ~p", [ClientId, Info]),
{noreply, Session}. {noreply, Session}.
terminate(_Reason, #session{clean_sess = CleanSess, client_id = ClientId}) -> terminate(_Reason, #session{clean_sess = CleanSess, client_id = ClientId}) ->

View File

@ -53,7 +53,7 @@ start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
init([]) -> init([]) ->
%%mnesia:subscribe(system), mnesia:subscribe(system),
{ok, TRef} = timer:send_interval(1000, tick), {ok, TRef} = timer:send_interval(1000, tick),
StatsFun = emqttd_stats:statsfun('sessions/count', 'sessions/max'), StatsFun = emqttd_stats:statsfun('sessions/count', 'sessions/max'),
{ok, #state{stats_fun = StatsFun, tick_tref = TRef}}. {ok, #state{stats_fun = StatsFun, tick_tref = TRef}}.
@ -62,7 +62,7 @@ handle_call(_Request, _From, State) ->
{reply, ok, State}. {reply, ok, State}.
handle_cast(Msg, State) -> handle_cast(Msg, State) ->
lager:critical("Unexpected Msg: ~p", [Msg]), lager:error("Unexpected Msg: ~p", [Msg]),
{noreply, State}. {noreply, State}.
handle_info({mnesia_system_event, {mnesia_down, Node}}, State) -> handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
@ -72,7 +72,7 @@ handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
mnesia:select(session, [{#mqtt_session{client_id = '$1', sess_pid = '$2'}, mnesia:select(session, [{#mqtt_session{client_id = '$1', sess_pid = '$2'},
[{'==', {node, '$2'}, Node}], [{'==', {node, '$2'}, Node}],
['$1']}]), ['$1']}]),
lists:foreach(fun(Id) -> mnesia:delete({session, Id}) end, ClientIds) lists:foreach(fun(ClientId) -> mnesia:delete({session, ClientId}) end, ClientIds)
end, end,
mnesia:async_dirty(Fun), mnesia:async_dirty(Fun),
{noreply, State}; {noreply, State};
@ -81,7 +81,7 @@ handle_info(tick, State) ->
{noreply, setstats(State), hibernate}; {noreply, setstats(State), hibernate};
handle_info(Info, State) -> handle_info(Info, State) ->
lager:critical("Unexpected Info: ~p", [Info]), lager:error("Unexpected Info: ~p", [Info]),
{noreply, State}. {noreply, State}.
terminate(_Reason, _State = #state{tick_tref = TRef}) -> terminate(_Reason, _State = #state{tick_tref = TRef}) ->

View File

@ -206,7 +206,7 @@ handle_info({'EXIT', WsPid, Reason}, State = #client_state{ws_pid = WsPid, proto
stop({shutdown, websocket_closed}, State); stop({shutdown, websocket_closed}, State);
handle_info(Info, State = #client_state{request = Req}) -> handle_info(Info, State = #client_state{request = Req}) ->
lager:critical("Client(WebSocket) ~s: Unexpected Info - ~p", [Req:get(peer), Info]), lager:error("Client(WebSocket) ~s: Unexpected Info - ~p", [Req:get(peer), Info]),
noreply(State). noreply(State).
terminate(Reason, #client_state{proto_state = ProtoState, keepalive = KeepAlive}) -> terminate(Reason, #client_state{proto_state = ProtoState, keepalive = KeepAlive}) ->