Tune the log level
This commit is contained in:
parent
50c312e736
commit
cc6696f8cb
|
@ -70,7 +70,7 @@ handle_request(Method, Path, Req) ->
|
||||||
|
|
||||||
http_publish(Req) ->
|
http_publish(Req) ->
|
||||||
Params = [{iolist_to_binary(Key), Val} || {Key, Val} <- mochiweb_request:parse_post(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),
|
Topics = topics(Params),
|
||||||
ClientId = get_value(<<"client">>, Params, http),
|
ClientId = get_value(<<"client">>, Params, http),
|
||||||
Qos = int(get_value(<<"qos">>, Params, "0")),
|
Qos = int(get_value(<<"qos">>, Params, "0")),
|
||||||
|
|
|
@ -156,8 +156,8 @@ load_app(App) ->
|
||||||
start_app(App, SuccFun) ->
|
start_app(App, SuccFun) ->
|
||||||
case application:ensure_all_started(App) of
|
case application:ensure_all_started(App) of
|
||||||
{ok, Started} ->
|
{ok, Started} ->
|
||||||
lager:info("started Apps: ~p", [Started]),
|
lager:info("Started Apps: ~p", [Started]),
|
||||||
lager:info("load plugin ~p successfully", [App]),
|
lager:info("Load plugin ~p successfully", [App]),
|
||||||
SuccFun(App),
|
SuccFun(App),
|
||||||
{ok, Started};
|
{ok, Started};
|
||||||
{error, {ErrApp, Reason}} ->
|
{error, {ErrApp, Reason}} ->
|
||||||
|
@ -196,11 +196,11 @@ unload_plugin(App, Persistent) ->
|
||||||
stop_app(App) ->
|
stop_app(App) ->
|
||||||
case application:stop(App) of
|
case application:stop(App) of
|
||||||
ok ->
|
ok ->
|
||||||
lager:info("stop plugin ~p successfully~n", [App]), ok;
|
lager:info("Stop plugin ~p successfully~n", [App]), ok;
|
||||||
{error, {not_started, App}} ->
|
{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} ->
|
{error, Reason} ->
|
||||||
lager:error("stop plugin ~p error: ~p", [App]), {error, Reason}
|
lager:error("Stop plugin ~p error: ~p", [App]), {error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -344,10 +344,10 @@ send(Packet = ?PACKET(Type),
|
||||||
{ok, State#proto_state{stats_data = Stats1}}.
|
{ok, State#proto_state{stats_data = Stats1}}.
|
||||||
|
|
||||||
trace(recv, Packet, ProtoState) ->
|
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) ->
|
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}) ->
|
inc_stats(_Direct, _Type, Stats = #proto_stats{enable_stats = false}) ->
|
||||||
Stats;
|
Stats;
|
||||||
|
@ -382,7 +382,7 @@ shutdown(conflict, #proto_state{client_id = _ClientId}) ->
|
||||||
ignore;
|
ignore;
|
||||||
|
|
||||||
shutdown(Error, State = #proto_state{will_msg = WillMsg}) ->
|
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),
|
Client = client(State),
|
||||||
send_willmsg(Client, WillMsg),
|
send_willmsg(Client, WillMsg),
|
||||||
emqttd_hooks:run('client.disconnected', [Error], Client),
|
emqttd_hooks:run('client.disconnected', [Error], Client),
|
||||||
|
|
|
@ -102,11 +102,11 @@ trace(publish, From, _Msg) when is_atom(From) ->
|
||||||
%% Dont' trace '$SYS' publish
|
%% Dont' trace '$SYS' publish
|
||||||
ignore;
|
ignore;
|
||||||
trace(publish, {ClientId, Username}, #mqtt_message{topic = Topic, payload = Payload}) ->
|
trace(publish, {ClientId, Username}, #mqtt_message{topic = Topic, payload = Payload}) ->
|
||||||
lager:info([{client, ClientId}, {topic, Topic}],
|
lager:debug([{client, ClientId}, {topic, Topic}],
|
||||||
"~s/~s PUBLISH to ~s: ~p", [ClientId, Username, Topic, Payload]);
|
"~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) ->
|
trace(publish, From, #mqtt_message{topic = Topic, payload = Payload}) ->
|
||||||
lager:info([{client, From}, {topic, Topic}],
|
lager:debug([{client, From}, {topic, Topic}],
|
||||||
"~s PUBLISH to ~s: ~p", [From, Topic, Payload]).
|
"~s PUBLISH to ~s: ~p", [From, Topic, Payload]).
|
||||||
|
|
||||||
%% @doc Unsubscribe
|
%% @doc Unsubscribe
|
||||||
-spec(unsubscribe(binary()) -> ok | emqttd:pubsub_error()).
|
-spec(unsubscribe(binary()) -> ok | emqttd:pubsub_error()).
|
||||||
|
|
|
@ -379,7 +379,7 @@ handle_cast({subscribe, _From, TopicTable, AckFun},
|
||||||
State = #state{client_id = ClientId,
|
State = #state{client_id = ClientId,
|
||||||
username = Username,
|
username = Username,
|
||||||
subscriptions = Subscriptions}) ->
|
subscriptions = Subscriptions}) ->
|
||||||
?LOG(info, "Subscribe ~p", [TopicTable], State),
|
?LOG(debug, "Subscribe ~p", [TopicTable], State),
|
||||||
{GrantedQos, Subscriptions1} =
|
{GrantedQos, Subscriptions1} =
|
||||||
lists:foldl(fun({Topic, Opts}, {QosAcc, SubMap}) ->
|
lists:foldl(fun({Topic, Opts}, {QosAcc, SubMap}) ->
|
||||||
NewQos = proplists:get_value(qos, Opts),
|
NewQos = proplists:get_value(qos, Opts),
|
||||||
|
@ -407,7 +407,7 @@ handle_cast({unsubscribe, _From, TopicTable},
|
||||||
State = #state{client_id = ClientId,
|
State = #state{client_id = ClientId,
|
||||||
username = Username,
|
username = Username,
|
||||||
subscriptions = Subscriptions}) ->
|
subscriptions = Subscriptions}) ->
|
||||||
?LOG(info, "Unsubscribe ~p", [TopicTable], State),
|
?LOG(debug, "Unsubscribe ~p", [TopicTable], State),
|
||||||
Subscriptions1 =
|
Subscriptions1 =
|
||||||
lists:foldl(fun({Topic, Opts}, SubMap) ->
|
lists:foldl(fun({Topic, Opts}, SubMap) ->
|
||||||
case maps:find(Topic, SubMap) of
|
case maps:find(Topic, SubMap) of
|
||||||
|
@ -482,7 +482,7 @@ handle_cast({resume, ClientId, ClientPid},
|
||||||
await_rel_timer = AwaitTimer,
|
await_rel_timer = AwaitTimer,
|
||||||
expiry_timer = ExpireTimer}) ->
|
expiry_timer = ExpireTimer}) ->
|
||||||
|
|
||||||
?LOG(info, "Resumed by ~p", [ClientPid], State),
|
?LOG(debug, "Resumed by ~p", [ClientPid], State),
|
||||||
|
|
||||||
%% Cancel Timers
|
%% Cancel Timers
|
||||||
lists:foreach(fun emqttd_misc:cancel_timer/1,
|
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})));
|
hibernate(expire_awaiting_rel(emit_stats(State#state{await_rel_timer = undefined})));
|
||||||
|
|
||||||
handle_info({timeout, _Timer, expired}, State) ->
|
handle_info({timeout, _Timer, expired}, State) ->
|
||||||
?LOG(info, "Expired, shutdown now.", [], State),
|
?LOG(debug, "Expired, shutdown now.", [], State),
|
||||||
shutdown(expired, State);
|
shutdown(expired, State);
|
||||||
|
|
||||||
handle_info({'EXIT', ClientPid, _Reason},
|
handle_info({'EXIT', ClientPid, _Reason},
|
||||||
|
@ -563,7 +563,7 @@ handle_info({'EXIT', ClientPid, Reason},
|
||||||
State = #state{clean_sess = false,
|
State = #state{clean_sess = false,
|
||||||
client_pid = ClientPid,
|
client_pid = ClientPid,
|
||||||
expiry_interval = Interval}) ->
|
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),
|
ExpireTimer = start_timer(Interval, expired),
|
||||||
State1 = State#state{client_pid = undefined, expiry_timer = ExpireTimer},
|
State1 = State#state{client_pid = undefined, expiry_timer = ExpireTimer},
|
||||||
hibernate(emit_stats(State1));
|
hibernate(emit_stats(State1));
|
||||||
|
|
|
@ -39,7 +39,7 @@ handle_request(Req) ->
|
||||||
%% MQTT Over WebSocket
|
%% MQTT Over WebSocket
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
handle_request('GET', "/mqtt", Req) ->
|
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"),
|
Upgrade = Req:get_header_value("Upgrade"),
|
||||||
Proto = check_protocol_header(Req),
|
Proto = check_protocol_header(Req),
|
||||||
case {is_websocket(Upgrade), Proto} of
|
case {is_websocket(Upgrade), Proto} of
|
||||||
|
|
Loading…
Reference in New Issue