From cc6696f8cb763858af4f50e90d48fd3dcd86fa2d Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Sun, 25 Jun 2017 07:11:36 +0800 Subject: [PATCH] Tune the log level --- src/emqttd_http.erl | 2 +- src/emqttd_plugins.erl | 10 +++++----- src/emqttd_protocol.erl | 6 +++--- src/emqttd_server.erl | 10 +++++----- src/emqttd_session.erl | 10 +++++----- src/emqttd_ws.erl | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/emqttd_http.erl b/src/emqttd_http.erl index cf705ff00..e09154245 100644 --- a/src/emqttd_http.erl +++ b/src/emqttd_http.erl @@ -70,7 +70,7 @@ handle_request(Method, Path, Req) -> http_publish(Req) -> Params = [{iolist_to_binary(Key), Val} || {Key, Val} <- mochiweb_request:parse_post(Req)], - lager:info("HTTP Publish: ~p", [Params]), + lager:debug("HTTP Publish: ~p", [Params]), Topics = topics(Params), ClientId = get_value(<<"client">>, Params, http), Qos = int(get_value(<<"qos">>, Params, "0")), diff --git a/src/emqttd_plugins.erl b/src/emqttd_plugins.erl index f126f631c..73f184a3a 100644 --- a/src/emqttd_plugins.erl +++ b/src/emqttd_plugins.erl @@ -156,8 +156,8 @@ load_app(App) -> start_app(App, SuccFun) -> case application:ensure_all_started(App) of {ok, Started} -> - lager:info("started Apps: ~p", [Started]), - lager:info("load plugin ~p successfully", [App]), + lager:info("Started Apps: ~p", [Started]), + lager:info("Load plugin ~p successfully", [App]), SuccFun(App), {ok, Started}; {error, {ErrApp, Reason}} -> @@ -196,11 +196,11 @@ unload_plugin(App, Persistent) -> stop_app(App) -> case application:stop(App) of ok -> - lager:info("stop plugin ~p successfully~n", [App]), ok; + lager:info("Stop plugin ~p successfully~n", [App]), ok; {error, {not_started, App}} -> - lager:error("plugin ~p is not started~n", [App]), ok; + lager:error("Plugin ~p is not started~n", [App]), ok; {error, Reason} -> - lager:error("stop plugin ~p error: ~p", [App]), {error, Reason} + lager:error("Stop plugin ~p error: ~p", [App]), {error, Reason} end. %%-------------------------------------------------------------------- diff --git a/src/emqttd_protocol.erl b/src/emqttd_protocol.erl index 433825253..b5be7c066 100644 --- a/src/emqttd_protocol.erl +++ b/src/emqttd_protocol.erl @@ -344,10 +344,10 @@ send(Packet = ?PACKET(Type), {ok, State#proto_state{stats_data = Stats1}}. trace(recv, Packet, ProtoState) -> - ?LOG(info, "RECV ~s", [emqttd_packet:format(Packet)], ProtoState); + ?LOG(debug, "RECV ~s", [emqttd_packet:format(Packet)], ProtoState); trace(send, Packet, ProtoState) -> - ?LOG(info, "SEND ~s", [emqttd_packet:format(Packet)], ProtoState). + ?LOG(debug, "SEND ~s", [emqttd_packet:format(Packet)], ProtoState). inc_stats(_Direct, _Type, Stats = #proto_stats{enable_stats = false}) -> Stats; @@ -382,7 +382,7 @@ shutdown(conflict, #proto_state{client_id = _ClientId}) -> ignore; shutdown(Error, State = #proto_state{will_msg = WillMsg}) -> - ?LOG(info, "Shutdown for ~p", [Error], State), + ?LOG(debug, "Shutdown for ~p", [Error], State), Client = client(State), send_willmsg(Client, WillMsg), emqttd_hooks:run('client.disconnected', [Error], Client), diff --git a/src/emqttd_server.erl b/src/emqttd_server.erl index ec57f2802..cde9208df 100644 --- a/src/emqttd_server.erl +++ b/src/emqttd_server.erl @@ -102,11 +102,11 @@ trace(publish, From, _Msg) when is_atom(From) -> %% Dont' trace '$SYS' publish ignore; trace(publish, {ClientId, Username}, #mqtt_message{topic = Topic, payload = Payload}) -> - lager:info([{client, ClientId}, {topic, Topic}], - "~s/~s PUBLISH to ~s: ~p", [ClientId, Username, Topic, Payload]); -trace(publish, From, #mqtt_message{topic = Topic, payload = Payload}) when is_binary(From); is_list(From) -> - lager:info([{client, From}, {topic, Topic}], - "~s PUBLISH to ~s: ~p", [From, Topic, Payload]). + lager:debug([{client, ClientId}, {topic, Topic}], + "~s/~s PUBLISH to ~s: ~p", [ClientId, Username, Topic, Payload]); +trace(publish, From, #mqtt_message{topic = Topic, payload = Payload}) -> + lager:debug([{client, From}, {topic, Topic}], + "~s PUBLISH to ~s: ~p", [From, Topic, Payload]). %% @doc Unsubscribe -spec(unsubscribe(binary()) -> ok | emqttd:pubsub_error()). diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index 02d23567f..59295c112 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -379,7 +379,7 @@ handle_cast({subscribe, _From, TopicTable, AckFun}, State = #state{client_id = ClientId, username = Username, subscriptions = Subscriptions}) -> - ?LOG(info, "Subscribe ~p", [TopicTable], State), + ?LOG(debug, "Subscribe ~p", [TopicTable], State), {GrantedQos, Subscriptions1} = lists:foldl(fun({Topic, Opts}, {QosAcc, SubMap}) -> NewQos = proplists:get_value(qos, Opts), @@ -407,7 +407,7 @@ handle_cast({unsubscribe, _From, TopicTable}, State = #state{client_id = ClientId, username = Username, subscriptions = Subscriptions}) -> - ?LOG(info, "Unsubscribe ~p", [TopicTable], State), + ?LOG(debug, "Unsubscribe ~p", [TopicTable], State), Subscriptions1 = lists:foldl(fun({Topic, Opts}, SubMap) -> case maps:find(Topic, SubMap) of @@ -482,7 +482,7 @@ handle_cast({resume, ClientId, ClientPid}, await_rel_timer = AwaitTimer, expiry_timer = ExpireTimer}) -> - ?LOG(info, "Resumed by ~p", [ClientPid], State), + ?LOG(debug, "Resumed by ~p", [ClientPid], State), %% Cancel Timers lists:foreach(fun emqttd_misc:cancel_timer/1, @@ -552,7 +552,7 @@ handle_info({timeout, _Timer, check_awaiting_rel}, State) -> hibernate(expire_awaiting_rel(emit_stats(State#state{await_rel_timer = undefined}))); handle_info({timeout, _Timer, expired}, State) -> - ?LOG(info, "Expired, shutdown now.", [], State), + ?LOG(debug, "Expired, shutdown now.", [], State), shutdown(expired, State); handle_info({'EXIT', ClientPid, _Reason}, @@ -563,7 +563,7 @@ handle_info({'EXIT', ClientPid, Reason}, State = #state{clean_sess = false, client_pid = ClientPid, expiry_interval = Interval}) -> - ?LOG(info, "Client ~p EXIT for ~p", [ClientPid, Reason], State), + ?LOG(debug, "Client ~p EXIT for ~p", [ClientPid, Reason], State), ExpireTimer = start_timer(Interval, expired), State1 = State#state{client_pid = undefined, expiry_timer = ExpireTimer}, hibernate(emit_stats(State1)); diff --git a/src/emqttd_ws.erl b/src/emqttd_ws.erl index dbf0ea08c..c7d0b2119 100644 --- a/src/emqttd_ws.erl +++ b/src/emqttd_ws.erl @@ -39,7 +39,7 @@ handle_request(Req) -> %% MQTT Over WebSocket %%-------------------------------------------------------------------- handle_request('GET', "/mqtt", Req) -> - lager:info("WebSocket Connection from: ~s", [Req:get(peer)]), + lager:debug("WebSocket Connection from: ~s", [Req:get(peer)]), Upgrade = Req:get_header_value("Upgrade"), Proto = check_protocol_header(Req), case {is_websocket(Upgrade), Proto} of