Feng Lee 10 лет назад
Родитель
Сommit
f57e6b43db

+ 4 - 4
src/emqttd_client.erl

@@ -110,7 +110,7 @@ handle_call(kick, _From, State) ->
     {stop, {shutdown, kick}, ok, State};
 
 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}.    
 
 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);
 
 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}.
 
 handle_info(timeout, State) ->
@@ -152,7 +152,7 @@ handle_info({inet_async, _Sock, _Ref, {error, Reason}}, State) ->
     network_error(Reason, State);
 
 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};
 
 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;
 
 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}.
 
 terminate(Reason, #state{peername = Peername,

+ 2 - 2
src/emqttd_cm.erl

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

+ 1 - 1
src/emqttd_pubsub.erl

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

+ 2 - 2
src/emqttd_retained.erl

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

+ 3 - 3
src/emqttd_session.erl

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

+ 4 - 4
src/emqttd_sm_helper.erl

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

+ 1 - 1
src/emqttd_ws_client.erl

@@ -206,7 +206,7 @@ handle_info({'EXIT', WsPid, Reason}, State = #client_state{ws_pid = WsPid, proto
     stop({shutdown, websocket_closed}, State);
 
 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).
 
 terminate(Reason, #client_state{proto_state = ProtoState, keepalive = KeepAlive}) ->