diff --git a/src/emqx_broker.erl b/src/emqx_broker.erl index cdf22f9d9..df5939ef5 100644 --- a/src/emqx_broker.erl +++ b/src/emqx_broker.erl @@ -214,7 +214,7 @@ safe_publish(Msg) when is_record(Msg, message) -> publish(Msg) catch _:Error:Stk-> - ?LOG(error, "Publish error: ~p~n~s~n~p", + ?LOG(error, "Publish error: ~0p~n~s~n~0p", [Error, emqx_message:format(Msg), Stk]) after [] diff --git a/src/emqx_cm.erl b/src/emqx_cm.erl index dd8b02e54..8224d85c9 100644 --- a/src/emqx_cm.erl +++ b/src/emqx_cm.erl @@ -276,7 +276,7 @@ discard_session(ClientId) when is_binary(ClientId) -> _:{noproc,_}:_Stk -> ok; _:{{shutdown,_},_}:_Stk -> ok; _:Error:_Stk -> - ?LOG(error, "Failed to discard ~p: ~p", [ChanPid, Error]) + ?LOG(error, "Failed to discard ~0p: ~0p", [ChanPid, Error]) end end, ChanPids) end. diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index 1f595d3fa..3554ae893 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -319,7 +319,7 @@ handle_msg({'$gen_call', From, Req}, State) -> end; handle_msg({Inet, _Sock, Data}, State) when Inet == tcp; Inet == ssl -> - ?LOG(debug, "RECV ~p", [Data]), + ?LOG(debug, "RECV ~0p", [Data]), Oct = iolist_size(Data), emqx_pd:inc_counter(incoming_bytes, Oct), ok = emqx_metrics:inc('bytes.received', Oct), @@ -513,7 +513,7 @@ parse_incoming(Data, Packets, State = #state{parse_state = ParseState}) -> parse_incoming(Rest, [Packet|Packets], NState) catch error:Reason:Stk -> - ?LOG(error, "~nParse failed for ~p~n~p~nFrame data:~p", + ?LOG(error, "~nParse failed for ~0p~n~0p~nFrame data:~0p", [Reason, Stk, Data]), {[{frame_error, Reason}|Packets], State} end. diff --git a/src/emqx_ctl.erl b/src/emqx_ctl.erl index b21ffde66..d2cbf9b04 100644 --- a/src/emqx_ctl.erl +++ b/src/emqx_ctl.erl @@ -106,7 +106,7 @@ run_command(Cmd, Args) when is_atom(Cmd) -> _ -> ok catch _:Reason:Stacktrace -> - ?ERROR("CMD Error:~p, Stacktrace:~p", [Reason, Stacktrace]), + ?ERROR("CMD Error:~0p, Stacktrace:~0p", [Reason, Stacktrace]), {error, Reason} end; [] -> diff --git a/src/emqx_hooks.erl b/src/emqx_hooks.erl index 062559eb3..d079a38c3 100644 --- a/src/emqx_hooks.erl +++ b/src/emqx_hooks.erl @@ -165,7 +165,7 @@ safe_execute(Fun, Args) -> Result -> Result catch _:Reason:Stacktrace -> - ?LOG(error, "Failed to execute ~p: ~p", [Fun, {Reason, Stacktrace}]), + ?LOG(error, "Failed to execute ~0p: ~0p", [Fun, {Reason, Stacktrace}]), ok end. diff --git a/src/emqx_listeners.erl b/src/emqx_listeners.erl index 2990878dd..948c8e8d5 100644 --- a/src/emqx_listeners.erl +++ b/src/emqx_listeners.erl @@ -51,7 +51,7 @@ start_listener({Proto, ListenOn, Options}) -> {ok, _} -> io:format("Start mqtt:~s listener on ~s successfully.~n", [Proto, format(ListenOn)]); {error, Reason} -> - io:format(standard_error, "Failed to start mqtt:~s listener on ~s - ~p~n!", + io:format(standard_error, "Failed to start mqtt:~s listener on ~s - ~0p~n!", [Proto, format(ListenOn), Reason]) end, StartRet. diff --git a/src/emqx_mod_acl_internal.erl b/src/emqx_mod_acl_internal.erl index e836bd574..e429d6899 100644 --- a/src/emqx_mod_acl_internal.erl +++ b/src/emqx_mod_acl_internal.erl @@ -101,6 +101,12 @@ rules_from_file(AclFile) -> Rules = [emqx_access_rule:compile(Term) || Term <- Terms], #{publish => [Rule || Rule <- Rules, filter(publish, Rule)], subscribe => [Rule || Rule <- Rules, filter(subscribe, Rule)]}; + {error, eacces} -> + ?LOG(alert, "Insufficient permissions to read the ~s file", [AclFile]), + #{}; + {error, enoent} -> + ?LOG(alert, "The ~s file does not exist", [AclFile]), + #{}; {error, Reason} -> ?LOG(alert, "Failed to read ~s: ~p", [AclFile, Reason]), #{} diff --git a/src/emqx_packet.erl b/src/emqx_packet.erl index b229a3e07..768bf79e1 100644 --- a/src/emqx_packet.erl +++ b/src/emqx_packet.erl @@ -442,7 +442,7 @@ format_variable(undefined, _) -> format_variable(Variable, undefined) -> format_variable(Variable); format_variable(Variable, Payload) -> - io_lib:format("~s, Payload=~p", [format_variable(Variable), Payload]). + io_lib:format("~s, Payload=~0p", [format_variable(Variable), Payload]). format_variable(#mqtt_packet_connect{ proto_ver = ProtoVer, @@ -460,7 +460,7 @@ format_variable(#mqtt_packet_connect{ Format = "ClientId=~s, ProtoName=~s, ProtoVsn=~p, CleanStart=~s, KeepAlive=~p, Username=~s, Password=~s", Args = [ClientId, ProtoName, ProtoVer, CleanStart, KeepAlive, Username, format_password(Password)], {Format1, Args1} = if - WillFlag -> {Format ++ ", Will(Q~p, R~p, Topic=~s, Payload=~p)", + WillFlag -> {Format ++ ", Will(Q~p, R~p, Topic=~s, Payload=~0p)", Args ++ [WillQoS, i(WillRetain), WillTopic, WillPayload]}; true -> {Format, Args} end, diff --git a/src/emqx_plugins.erl b/src/emqx_plugins.erl index b6e2b6156..15c4ea330 100644 --- a/src/emqx_plugins.erl +++ b/src/emqx_plugins.erl @@ -283,7 +283,7 @@ start_app(App, SuccFun) -> SuccFun(App), ok; {error, {ErrApp, Reason}} -> - ?LOG(error, "Load plugin ~s failed, cannot start plugin ~s for ~p", [App, ErrApp, Reason]), + ?LOG(error, "Load plugin ~s failed, cannot start plugin ~s for ~0p", [App, ErrApp, Reason]), {error, {ErrApp, Reason}} end. diff --git a/src/emqx_pool.erl b/src/emqx_pool.erl index 10b1adf00..49a7c2cac 100644 --- a/src/emqx_pool.erl +++ b/src/emqx_pool.erl @@ -107,7 +107,7 @@ handle_call(Req, _From, State) -> handle_cast({async_submit, Task}, State) -> try run(Task) catch _:Error:Stacktrace -> - ?LOG(error, "Error: ~p, ~p", [Error, Stacktrace]) + ?LOG(error, "Error: ~0p, ~0p", [Error, Stacktrace]) end, {noreply, State}; diff --git a/src/emqx_psk.erl b/src/emqx_psk.erl index a74f5a390..f1170d2d9 100644 --- a/src/emqx_psk.erl +++ b/src/emqx_psk.erl @@ -35,6 +35,6 @@ lookup(psk, ClientPSKID, _UserState) -> error catch Except:Error:Stacktrace -> - ?LOG(error, "Lookup PSK failed, ~p: ~p", [{Except,Error}, Stacktrace]), + ?LOG(error, "Lookup PSK failed, ~0p: ~0p", [{Except,Error}, Stacktrace]), error end. diff --git a/src/emqx_stats.erl b/src/emqx_stats.erl index 95bfc88ae..7548867e5 100644 --- a/src/emqx_stats.erl +++ b/src/emqx_stats.erl @@ -243,7 +243,7 @@ handle_info({timeout, TRef, tick}, State = #state{timer = TRef, updates = Update try UpFun() catch _:Error -> - ?LOG(error, "Update ~s failed: ~p", [Name, Error]) + ?LOG(error, "Update ~s failed: ~0p", [Name, Error]) end, [Update#update{countdown = I} | Acc]; (Update = #update{countdown = C}, Acc) -> @@ -272,6 +272,6 @@ safe_update_element(Key, Val) -> true -> true catch error:badarg -> - ?LOG(warning, "Failed to update ~p to ~p", [Key, Val]) + ?LOG(warning, "Failed to update ~0p to ~0p", [Key, Val]) end. diff --git a/src/emqx_tracer.erl b/src/emqx_tracer.erl index 96dbe04d2..a2112cda3 100644 --- a/src/emqx_tracer.erl +++ b/src/emqx_tracer.erl @@ -65,7 +65,7 @@ trace(publish, #message{topic = <<"$SYS/", _/binary>>}) -> ignore; trace(publish, #message{from = From, topic = Topic, payload = Payload}) when is_binary(From); is_atom(From) -> - emqx_logger:info(#{topic => Topic, mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY} }, "PUBLISH to ~s: ~p", [Topic, Payload]). + emqx_logger:info(#{topic => Topic, mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY} }, "PUBLISH to ~s: ~0p", [Topic, Payload]). %% @doc Start to trace clientid or topic. -spec(start_trace(trace_who(), logger:level(), string()) -> ok | {error, term()}). diff --git a/src/emqx_ws_connection.erl b/src/emqx_ws_connection.erl index 97fb5e623..f26bfb70e 100644 --- a/src/emqx_ws_connection.erl +++ b/src/emqx_ws_connection.erl @@ -200,7 +200,7 @@ websocket_init([Req, Opts]) -> ?LOG(error, "Illegal cookie"), undefined; Error:Reason -> - ?LOG(error, "Failed to parse cookie, Error: ~p, Reason ~p", + ?LOG(error, "Failed to parse cookie, Error: ~0p, Reason ~0p", [Error, Reason]), undefined end, @@ -245,7 +245,7 @@ websocket_handle({binary, Data}, State) when is_list(Data) -> websocket_handle({binary, iolist_to_binary(Data)}, State); websocket_handle({binary, Data}, State) -> - ?LOG(debug, "RECV ~p", [Data]), + ?LOG(debug, "RECV ~0p", [Data]), ok = inc_recv_stats(1, iolist_size(Data)), NState = ensure_stats_timer(State), return(parse_incoming(Data, NState)); @@ -458,7 +458,7 @@ parse_incoming(Data, State = #state{parse_state = ParseState}) -> parse_incoming(Rest, postpone({incoming, Packet}, NState)) catch error:Reason:Stk -> - ?LOG(error, "~nParse failed for ~p~n~p~nFrame data: ~p", + ?LOG(error, "~nParse failed for ~0p~n~0p~nFrame data: ~0p", [Reason, Stk, Data]), FrameError = {frame_error, Reason}, postpone({incoming, FrameError}, State)