Merge pull request #5913 from lafirest/fix/format

fix: change all ~s in io format to ~ts
This commit is contained in:
lafirest 2021-10-12 16:26:28 +08:00 committed by GitHub
commit 5dc11e5323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 255 additions and 255 deletions

View File

@ -81,7 +81,7 @@ set_debug_secret(PathToSecretFile) ->
catch _ : _ -> error({badfile, PathToSecretFile})
end;
{error, Reason} ->
?ULOG("Failed to read debug_info encryption key file ~s: ~p~n",
?ULOG("Failed to read debug_info encryption key file ~ts: ~p~n",
[PathToSecretFile, Reason]),
error(Reason)
end,

View File

@ -415,16 +415,16 @@ normalize_message(high_system_memory_usage, #{high_watermark := HighWatermark})
normalize_message(high_process_memory_usage, #{high_watermark := HighWatermark}) ->
list_to_binary(io_lib:format("Process memory usage is higher than ~p%", [HighWatermark]));
normalize_message(high_cpu_usage, #{usage := Usage}) ->
list_to_binary(io_lib:format("~s cpu usage", [Usage]));
list_to_binary(io_lib:format("~ts cpu usage", [Usage]));
normalize_message(too_many_processes, #{usage := Usage}) ->
list_to_binary(io_lib:format("~s process usage", [Usage]));
list_to_binary(io_lib:format("~ts process usage", [Usage]));
normalize_message(cluster_rpc_apply_failed, #{tnx_id := TnxId}) ->
list_to_binary(io_lib:format("cluster_rpc_apply_failed:~w", [TnxId]));
normalize_message(partition, #{occurred := Node}) ->
list_to_binary(io_lib:format("Partition occurs at node ~s", [Node]));
list_to_binary(io_lib:format("Partition occurs at node ~ts", [Node]));
normalize_message(<<"resource", _/binary>>, #{type := Type, id := ID}) ->
list_to_binary(io_lib:format("Resource ~s(~s) is down", [Type, ID]));
list_to_binary(io_lib:format("Resource ~ts(~ts) is down", [Type, ID]));
normalize_message(<<"conn_congestion/", Info/binary>>, _) ->
list_to_binary(io_lib:format("connection congested: ~s", [Info]));
list_to_binary(io_lib:format("connection congested: ~ts", [Info]));
normalize_message(_Name, _UnknownDetails) ->
<<"Unknown alarm">>.

View File

@ -57,8 +57,8 @@ run(#{subscribers := Subs,
lists:foreach(fun(Pid) -> Pid ! start_subscribe end, SubsPids),
collect_results(SubsPids, subscribe_time)
end),
io:format(user, "InsertTotalTime: ~s~n", [ns(T1)]),
io:format(user, "InsertTimeAverage: ~s~n", [ns(SubsTime / Subs)]),
io:format(user, "InsertTotalTime: ~ts~n", [ns(T1)]),
io:format(user, "InsertTimeAverage: ~ts~n", [ns(SubsTime / Subs)]),
io:format(user, "InsertRps: ~p~n", [rps(Subs * SubOps, T1)]),
io:format(user, "lookup ...~n", []),
@ -67,8 +67,8 @@ run(#{subscribers := Subs,
lists:foreach(fun(Pid) -> Pid ! start_lookup end, PubsPids),
collect_results(PubsPids, lookup_time)
end),
io:format(user, "LookupTotalTime: ~s~n", [ns(T2)]),
io:format(user, "LookupTimeAverage: ~s~n", [ns(PubsTime / Pubs)]),
io:format(user, "LookupTotalTime: ~ts~n", [ns(T2)]),
io:format(user, "LookupTimeAverage: ~ts~n", [ns(PubsTime / Pubs)]),
io:format(user, "LookupRps: ~p~n", [rps(Pubs * PubOps, T2)]),
io:format(user, "mnesia table(s) RAM: ~p~n", [ram_bytes()]),
@ -79,7 +79,7 @@ run(#{subscribers := Subs,
lists:foreach(fun(Pid) -> Pid ! stop end, SubsPids),
wait_until_empty()
end),
io:format(user, "TimeToUnsubscribeAll: ~s~n", [ns(T3)]).
io:format(user, "TimeToUnsubscribeAll: ~ts~n", [ns(T3)]).
wait_until_empty() ->
case emqx_trie:empty() of

View File

@ -22,7 +22,7 @@
-define(ALARM_CONN_CONGEST(Channel, Reason),
list_to_binary(
io_lib:format("~s/~s/~s",
io_lib:format("~ts/~ts/~ts",
[Reason, emqx_channel:info(clientid, Channel),
maps:get(username, emqx_channel:info(clientinfo, Channel),
<<"unknown_user">>)]))).

View File

@ -116,7 +116,7 @@
-define(ENABLED(X), (X =/= undefined)).
-define(ALARM_TCP_CONGEST(Channel),
list_to_binary(io_lib:format("mqtt_conn/congested/~s/~s",
list_to_binary(io_lib:format("mqtt_conn/congested/~ts/~ts",
[emqx_channel:info(clientid, Channel),
emqx_channel:info(username, Channel)]))).

View File

@ -128,7 +128,7 @@ help() ->
[] ->
print("No commands available.~n");
Cmds ->
print("Usage: ~s~n", [?MODULE]),
print("Usage: ~ts~n", [?MODULE]),
lists:foreach(fun({_, {Mod, Cmd}, _}) ->
print("~110..-s~n", [""]), Mod:Cmd(usage)
end, Cmds)
@ -136,11 +136,11 @@ help() ->
-spec(print(io:format()) -> ok).
print(Msg) ->
io:format("~s", [format(Msg)]).
io:format("~ts", [format(Msg)]).
-spec(print(io:format(), [term()]) -> ok).
print(Format, Args) ->
io:format("~s", [format(Format, Args)]).
io:format("~ts", [format(Format, Args)]).
-spec(usage([cmd_usage()]) -> ok).
usage(UsageList) ->
@ -152,7 +152,7 @@ usage(CmdParams, Desc) ->
-spec(format(io:format()) -> string()).
format(Msg) ->
lists:flatten(io_lib:format("~s", [Msg])).
lists:flatten(io_lib:format("~ts", [Msg])).
-spec(format(io:format(), [term()]) -> string()).
format(Format, Args) ->
@ -170,7 +170,7 @@ format_usage(CmdParams, Desc) ->
CmdLines = split_cmd(CmdParams),
DescLines = split_cmd(Desc),
lists:foldl(fun({CmdStr, DescStr}, Usage) ->
Usage ++ format("~-70s# ~s~n", [CmdStr, DescStr])
Usage ++ format("~-70s# ~ts~n", [CmdStr, DescStr])
end, "", zip_cmd(CmdLines, DescLines)).
%%--------------------------------------------------------------------

View File

@ -131,15 +131,15 @@ start_listener(Type, ListenerName, #{bind := Bind} = Conf) ->
case do_start_listener(Type, ListenerName, Conf) of
{ok, {skipped, Reason}} when Reason =:= listener_disabled;
Reason =:= quic_app_missing ->
console_print("- Skip - starting listener ~s on ~s ~n due to ~p",
console_print("- Skip - starting listener ~ts on ~ts ~n due to ~p",
[listener_id(Type, ListenerName), format_addr(Bind), Reason]);
{ok, _} ->
console_print("Listener ~s on ~s started.~n",
console_print("Listener ~ts on ~ts started.~n",
[listener_id(Type, ListenerName), format_addr(Bind)]);
{error, {already_started, Pid}} ->
{error, {already_started, Pid}};
{error, Reason} ->
?ELOG("Failed to start listener ~s on ~s: ~0p~n",
?ELOG("Failed to start listener ~ts on ~ts: ~0p~n",
[listener_id(Type, ListenerName), format_addr(Bind), Reason]),
error(Reason)
end.
@ -180,11 +180,11 @@ stop_listener(ListenerId) ->
stop_listener(Type, ListenerName, #{bind := Bind} = Conf) ->
case do_stop_listener(Type, ListenerName, Conf) of
ok ->
console_print("Listener ~s on ~s stopped.~n",
console_print("Listener ~ts on ~ts stopped.~n",
[listener_id(Type, ListenerName), format_addr(Bind)]),
ok;
{error, Reason} ->
?ELOG("Failed to stop listener ~s on ~s: ~0p~n",
?ELOG("Failed to stop listener ~ts on ~ts: ~0p~n",
[listener_id(Type, ListenerName), format_addr(Bind), Reason]),
{error, Reason}
end.
@ -342,9 +342,9 @@ merge_default(Options) ->
format_addr(Port) when is_integer(Port) ->
io_lib:format("0.0.0.0:~w", [Port]);
format_addr({Addr, Port}) when is_list(Addr) ->
io_lib:format("~s:~w", [Addr, Port]);
io_lib:format("~ts:~w", [Addr, Port]);
format_addr({Addr, Port}) when is_tuple(Addr) ->
io_lib:format("~s:~w", [inet:ntoa(Addr), Port]).
io_lib:format("~ts:~w", [inet:ntoa(Addr), Port]).
listener_id(Type, ListenerName) ->
list_to_atom(lists:append([str(Type), ":", str(ListenerName)])).

View File

@ -32,7 +32,7 @@ enrich(Report, #{mfa := Mfa, line := Line}) ->
enrich(Report, _) -> Report.
enrich_fmt({Fmt, Args}, #{mfa := Mfa, line := Line}) when is_list(Fmt) ->
{Fmt ++ " mfa: ~s line: ~w", Args ++ [mfa(Mfa), Line]};
{Fmt ++ " mfa: ~ts line: ~w", Args ++ [mfa(Mfa), Line]};
enrich_fmt(Msg, _) ->
Msg.

View File

@ -446,14 +446,14 @@ format_header(#mqtt_packet_header{type = Type,
true -> <<>>;
false -> [", ", S]
end,
io_lib:format("~s(Q~p, R~p, D~p~s)", [type_name(Type), QoS, i(Retain), i(Dup), S1]).
io_lib:format("~ts(Q~p, R~p, D~p~ts)", [type_name(Type), QoS, i(Retain), i(Dup), S1]).
format_variable(undefined, _) ->
undefined;
format_variable(Variable, undefined) ->
format_variable(Variable);
format_variable(Variable, Payload) ->
io_lib:format("~s, Payload=~0p", [format_variable(Variable), Payload]).
io_lib:format("~ts, Payload=~0p", [format_variable(Variable), Payload]).
format_variable(#mqtt_packet_connect{
proto_ver = ProtoVer,
@ -468,10 +468,10 @@ format_variable(#mqtt_packet_connect{
will_payload = WillPayload,
username = Username,
password = Password}) ->
Format = "ClientId=~s, ProtoName=~s, ProtoVsn=~p, CleanStart=~s, KeepAlive=~p, Username=~s, Password=~s",
Format = "ClientId=~ts, ProtoName=~ts, ProtoVsn=~p, CleanStart=~ts, KeepAlive=~p, Username=~ts, Password=~ts",
Args = [ClientId, ProtoName, ProtoVer, CleanStart, KeepAlive, Username, format_password(Password)],
{Format1, Args1} = if
WillFlag -> {Format ++ ", Will(Q~p, R~p, Topic=~s, Payload=~0p)",
WillFlag -> {Format ++ ", Will(Q~p, R~p, Topic=~ts, Payload=~0p)",
Args ++ [WillQoS, i(WillRetain), WillTopic, WillPayload]};
true -> {Format, Args}
end,
@ -487,7 +487,7 @@ format_variable(#mqtt_packet_connack{ack_flags = AckFlags,
format_variable(#mqtt_packet_publish{topic_name = TopicName,
packet_id = PacketId}) ->
io_lib:format("Topic=~s, PacketId=~p", [TopicName, PacketId]);
io_lib:format("Topic=~ts, PacketId=~p", [TopicName, PacketId]);
format_variable(#mqtt_packet_puback{packet_id = PacketId,
reason_code = ReasonCode}) ->

View File

@ -151,7 +151,7 @@ load_ext_plugin(PluginDir) ->
% catch
% throw : {conf_file_not_found, ConfFile} ->
% %% this is maybe a dependency of an external plugin
% ?LOG(debug, "config_load_error_ignored for app=~p, path=~s", [AppName, ConfFile]),
% ?LOG(debug, "config_load_error_ignored for app=~p, path=~ts", [AppName, ConfFile]),
% ok
% end.

View File

@ -177,7 +177,7 @@ topics() ->
-spec(print_routes(emqx_types:topic()) -> ok).
print_routes(Topic) ->
lists:foreach(fun(#route{topic = To, dest = Dest}) ->
io:format("~s -> ~s~n", [To, Dest])
io:format("~ts -> ~ts~n", [To, Dest])
end, match_routes(Topic)).
call(Router, Msg) ->

View File

@ -1280,7 +1280,7 @@ validate_heap_size(Siz) ->
(1 bsl 27) - 1
end,
case Siz > MaxSiz of
true -> error(io_lib:format("force_shutdown_policy: heap-size ~s is too large", [Siz]));
true -> error(io_lib:format("force_shutdown_policy: heap-size ~ts is too large", [Siz]));
false -> ok
end.
parse_user_lookup_fun(StrConf) ->

View File

@ -70,7 +70,7 @@ 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: ~0p", [Topic, Payload]).
"PUBLISH to ~ts: ~0p", [Topic, Payload]).
%% @doc Start to trace clientid or topic.
-spec(start_trace(trace_who(), logger:level() | all, string()) -> ok | {error, term()}).
@ -83,8 +83,8 @@ start_trace(Who, Level, LogFile) ->
try logger:compare_levels(Level, PrimaryLevel) of
lt ->
{error,
io_lib:format("Cannot trace at a log level (~s) "
"lower than the primary log level (~s)",
io_lib:format("Cannot trace at a log level (~ts) "
"lower than the primary log level (~ts)",
[Level, PrimaryLevel])};
_GtOrEq ->
install_trace_handler(Who, Level, LogFile)

View File

@ -66,13 +66,13 @@ t_run_commands(_) ->
t_print(_) ->
ok = emqx_ctl:print("help"),
ok = emqx_ctl:print("~s", [help]),
ok = emqx_ctl:print("~s", [<<"~!@#$%^&*()">>]),
ok = emqx_ctl:print("~ts", [help]),
ok = emqx_ctl:print("~ts", [<<"~!@#$%^&*()">>]),
% - check the output of the usage
mock_print(),
?assertEqual("help", emqx_ctl:print("help")),
?assertEqual("help", emqx_ctl:print("~s", [help])),
?assertEqual("~!@#$%^&*()", emqx_ctl:print("~s", [<<"~!@#$%^&*()">>])),
?assertEqual("help", emqx_ctl:print("~ts", [help])),
?assertEqual("~!@#$%^&*()", emqx_ctl:print("~ts", [<<"~!@#$%^&*()">>])),
unmock_print().
t_usage(_) ->

View File

@ -290,24 +290,24 @@ t_will_msg(_) ->
?assertEqual(<<"topic">>, Msg2#message.topic).
t_format(_) ->
io:format("~s", [emqx_packet:format(#mqtt_packet{header = #mqtt_packet_header{type = ?CONNACK, retain = true, dup = 0}, variable = undefined})]),
io:format("~s", [emqx_packet:format(#mqtt_packet{header = #mqtt_packet_header{type = ?CONNACK}, variable = 1, payload = <<"payload">>})]),
io:format("~s", [emqx_packet:format(?CONNECT_PACKET(#mqtt_packet_connect{will_flag = true,
io:format("~ts", [emqx_packet:format(#mqtt_packet{header = #mqtt_packet_header{type = ?CONNACK, retain = true, dup = 0}, variable = undefined})]),
io:format("~ts", [emqx_packet:format(#mqtt_packet{header = #mqtt_packet_header{type = ?CONNACK}, variable = 1, payload = <<"payload">>})]),
io:format("~ts", [emqx_packet:format(?CONNECT_PACKET(#mqtt_packet_connect{will_flag = true,
will_retain = true,
will_qos = ?QOS_2,
will_topic = <<"topic">>,
will_payload = <<"payload">>}))]),
io:format("~s", [emqx_packet:format(?CONNECT_PACKET(#mqtt_packet_connect{password = password}))]),
io:format("~s", [emqx_packet:format(?CONNACK_PACKET(?CONNACK_SERVER))]),
io:format("~s", [emqx_packet:format(?PUBLISH_PACKET(?QOS_1, 1))]),
io:format("~s", [emqx_packet:format(?PUBLISH_PACKET(?QOS_2, <<"topic">>, 10, <<"payload">>))]),
io:format("~s", [emqx_packet:format(?PUBACK_PACKET(?PUBACK, 98))]),
io:format("~s", [emqx_packet:format(?PUBREL_PACKET(99))]),
io:format("~s", [emqx_packet:format(?SUBSCRIBE_PACKET(15, [{<<"topic">>, ?QOS_0}, {<<"topic1">>, ?QOS_1}]))]),
io:format("~s", [emqx_packet:format(?SUBACK_PACKET(40, [?QOS_0, ?QOS_1]))]),
io:format("~s", [emqx_packet:format(?UNSUBSCRIBE_PACKET(89, [<<"t">>, <<"t2">>]))]),
io:format("~s", [emqx_packet:format(?UNSUBACK_PACKET(90))]),
io:format("~s", [emqx_packet:format(?DISCONNECT_PACKET(128))]).
io:format("~ts", [emqx_packet:format(?CONNECT_PACKET(#mqtt_packet_connect{password = password}))]),
io:format("~ts", [emqx_packet:format(?CONNACK_PACKET(?CONNACK_SERVER))]),
io:format("~ts", [emqx_packet:format(?PUBLISH_PACKET(?QOS_1, 1))]),
io:format("~ts", [emqx_packet:format(?PUBLISH_PACKET(?QOS_2, <<"topic">>, 10, <<"payload">>))]),
io:format("~ts", [emqx_packet:format(?PUBACK_PACKET(?PUBACK, 98))]),
io:format("~ts", [emqx_packet:format(?PUBREL_PACKET(99))]),
io:format("~ts", [emqx_packet:format(?SUBSCRIBE_PACKET(15, [{<<"topic">>, ?QOS_0}, {<<"topic1">>, ?QOS_1}]))]),
io:format("~ts", [emqx_packet:format(?SUBACK_PACKET(40, [?QOS_0, ?QOS_1]))]),
io:format("~ts", [emqx_packet:format(?UNSUBSCRIBE_PACKET(89, [<<"t">>, <<"t2">>]))]),
io:format("~ts", [emqx_packet:format(?UNSUBACK_PACKET(90))]),
io:format("~ts", [emqx_packet:format(?DISCONNECT_PACKET(128))]).
t_parse_empty_publish(_) ->
%% 52: 0011(type=PUBLISH) 0100 (QoS=2)

View File

@ -31,14 +31,14 @@ init_per_suite(Config) ->
DataPath = proplists:get_value(data_dir, Config),
AppPath = filename:join([DataPath, "emqx_mini_plugin"]),
HoconPath = filename:join([DataPath, "emqx_hocon_plugin"]),
Cmd = lists:flatten(io_lib:format("cd ~s && make", [AppPath])),
CmdPath = lists:flatten(io_lib:format("cd ~s && make", [HoconPath])),
Cmd = lists:flatten(io_lib:format("cd ~ts && make", [AppPath])),
CmdPath = lists:flatten(io_lib:format("cd ~ts && make", [HoconPath])),
ct:pal("Executing ~s~n", [Cmd]),
ct:pal("~n ~s~n", [os:cmd(Cmd)]),
ct:pal("Executing ~ts~n", [Cmd]),
ct:pal("~n ~ts~n", [os:cmd(Cmd)]),
ct:pal("Executing ~s~n", [CmdPath]),
ct:pal("~n ~s~n", [os:cmd(CmdPath)]),
ct:pal("Executing ~ts~n", [CmdPath]),
ct:pal("~n ~ts~n", [os:cmd(CmdPath)]),
emqx_ct_helpers:boot_modules([]),
emqx_ct_helpers:start_apps([]),

View File

@ -65,7 +65,7 @@ handle_msg(ReqMsg, RequestHandler, Parent) ->
props = RspProps,
payload = RspPayload
},
emqx_logger:debug("~p sending response msg to topic ~s with~n"
emqx_logger:debug("~p sending response msg to topic ~ts with~n"
"corr-data=~p~npayload=~p",
[?MODULE, RspTopic, CorrData, RspPayload]),
ok = send_response(RspMsg);

View File

@ -214,5 +214,5 @@ bench(Case, Fun, Args) ->
[fun(_) -> apply(Fun, Args) end,
lists:seq(1, ?N)
]),
ct:pal("Time consumed by ~s: ~.3f(us)~nCall ~s per second: ~w",
ct:pal("Time consumed by ~ts: ~.3f(us)~nCall ~ts per second: ~w",
[Case, Time/?N, Case, (?N * 1000000) div Time]).

View File

@ -1991,13 +1991,13 @@ convert_certs(Config) ->
serialize_error({not_found, {authenticator, ID}}) ->
{404, #{code => <<"NOT_FOUND">>,
message => list_to_binary(
io_lib:format("Authenticator '~s' does not exist", [ID])
io_lib:format("Authenticator '~ts' does not exist", [ID])
)}};
serialize_error({not_found, {listener, ID}}) ->
{404, #{code => <<"NOT_FOUND">>,
message => list_to_binary(
io_lib:format("Listener '~s' does not exist", [ID])
io_lib:format("Listener '~ts' does not exist", [ID])
)}};
serialize_error({not_found, {chain, ?GLOBAL}}) ->
@ -2007,13 +2007,13 @@ serialize_error({not_found, {chain, ?GLOBAL}}) ->
serialize_error({not_found, {chain, Name}}) ->
{400, #{code => <<"BAD_REQUEST">>,
message => list_to_binary(
io_lib:format("No authentication has been create for listener '~s'", [Name])
io_lib:format("No authentication has been create for listener '~ts'", [Name])
)}};
serialize_error({already_exists, {authenticator, ID}}) ->
{409, #{code => <<"ALREADY_EXISTS">>,
message => list_to_binary(
io_lib:format("Authenticator '~s' already exist", [ID])
io_lib:format("Authenticator '~ts' already exist", [ID])
)}};
serialize_error(no_available_provider) ->

View File

@ -202,13 +202,13 @@ init_source(#{type := file,
{ok, Terms} ->
[emqx_authz_rule:compile(Term) || Term <- Terms];
{error, eacces} ->
?LOG(alert, "Insufficient permissions to read the ~s file", [Path]),
?LOG(alert, "Insufficient permissions to read the ~ts file", [Path]),
error(eaccess);
{error, enoent} ->
?LOG(alert, "The ~s file does not exist", [Path]),
?LOG(alert, "The ~ts file does not exist", [Path]),
error(enoent);
{error, Reason} ->
?LOG(alert, "Failed to read ~s: ~p", [Path, Reason]),
?LOG(alert, "Failed to read ~ts: ~p", [Path, Reason]),
error(Reason)
end,
Source#{annotations => #{rules => Rules}};
@ -315,7 +315,7 @@ find_action_in_hooks() ->
Action.
gen_id(Type) ->
iolist_to_binary([io_lib:format("~s_~s",[?APP, Type])]).
iolist_to_binary([io_lib:format("~ts_~ts",[?APP, Type])]).
create_resource(#{type := DB,
annotations := #{id := ResourceID}} = Source) ->

View File

@ -177,7 +177,7 @@ query() ->
connector_fields(DB) ->
connector_fields(DB, config).
connector_fields(DB, Fields) ->
Mod0 = io_lib:format("~s_~s",[emqx_connector, DB]),
Mod0 = io_lib:format("~ts_~ts",[emqx_connector, DB]),
Mod = try
list_to_existing_atom(Mod0)
catch

View File

@ -69,13 +69,13 @@ start_listeners() ->
[begin
Minirest = maps:put(protocol, Protocol, BaseMinirest),
{ok, _} = minirest:start(Name, RanchOptions, Minirest),
?ULOG("Start listener ~s on ~p successfully.~n", [Name, Port])
?ULOG("Start listener ~ts on ~p successfully.~n", [Name, Port])
end || {Name, Protocol, Port, RanchOptions} <- listeners()].
stop_listeners() ->
[begin
ok = minirest:stop(Name),
?ULOG("Stop listener ~s on ~p successfully.~n", [Name, Port])
?ULOG("Stop listener ~ts on ~p successfully.~n", [Name, Port])
end || {Name, _, Port, _} <- listeners()].
%%--------------------------------------------------------------------

View File

@ -75,7 +75,7 @@ translate_req(Request, #{module := Module, path := Path, method := Method}) ->
catch throw:Error ->
{_, [{validation_error, ValidErr}]} = Error,
#{path := Key, reason := Reason} = ValidErr,
{400, 'BAD_REQUEST', iolist_to_binary(io_lib:format("~s : ~p", [Key, Reason]))}
{400, 'BAD_REQUEST', iolist_to_binary(io_lib:format("~ts : ~p", [Key, Reason]))}
end.
namespace() -> "public".

View File

@ -23,7 +23,7 @@
cli(["server", "list"]) ->
if_enabled(fun() ->
ServerNames = emqx_exhook:list(),
[emqx_ctl:print("Server(~s)~n", [format(Name)]) || Name <- ServerNames]
[emqx_ctl:print("Server(~ts)~n", [format(Name)]) || Name <- ServerNames]
end);
cli(["server", "enable", Name]) ->
@ -78,7 +78,7 @@ format(Name) ->
case emqx_exhook_mngr:server(Name) of
undefined ->
lists:flatten(
io_lib:format("name=~s, hooks=#{}, active=false", [Name]));
io_lib:format("name=~ts, hooks=#{}, active=false", [Name]));
Server ->
emqx_exhook_server:format(Server)
end.

View File

@ -185,7 +185,7 @@ handle_info({timeout, _Ref, {reload, Name}}, State) ->
{error, not_found} ->
{noreply, NState};
{error, Reason} ->
?LOG(warning, "Failed to reload exhook callback server \"~s\", "
?LOG(warning, "Failed to reload exhook callback server \"~ts\", "
"Reason: ~0p", [Name, Reason]),
{noreply, ensure_reload_timer(NState)}
end;
@ -231,7 +231,7 @@ do_load_server(Name, State0 = #state{
{ok, ServerState} ->
save(Name, ServerState),
?LOG(info, "Load exhook callback server "
"\"~s\" successfully!", [Name]),
"\"~ts\" successfully!", [Name]),
{ok, State#state{
running = maps:put(Name, Options, Running),
waiting = maps:remove(Name, Waiting),

View File

@ -91,7 +91,7 @@ load(Name, Opts0, ReqOpts) ->
{ok, HookSpecs} ->
%% Reigster metrics
Prefix = lists:flatten(
io_lib:format("exhook.~s.", [Name])),
io_lib:format("exhook.~ts.", [Name])),
ensure_metrics(Prefix, HookSpecs),
%% Ensure hooks
ensure_hooks(HookSpecs),
@ -129,7 +129,7 @@ channel_opts(Opts = #{url := URL}) ->
end.
format_http_uri(Scheme, Host, Port) ->
lists:flatten(io_lib:format("~s://~s:~w", [Scheme, Host, Port])).
lists:flatten(io_lib:format("~ts://~ts:~w", [Scheme, Host, Port])).
filter(Ls) ->
[ E || E <- Ls, E /= undefined].
@ -194,7 +194,7 @@ ensure_hooks(HookSpecs) ->
lists:foreach(fun(Hookpoint) ->
case lists:keyfind(Hookpoint, 1, ?ENABLED_HOOKS) of
false ->
?LOG(error, "Unknown name ~s to hook, skip it!", [Hookpoint]);
?LOG(error, "Unknown name ~ts to hook, skip it!", [Hookpoint]);
{Hookpoint, {M, F, A}} ->
emqx_hooks:put(Hookpoint, {M, F, A}),
ets:update_counter(?CNTER, Hookpoint, {2, 1}, {Hookpoint, 0})
@ -217,7 +217,7 @@ may_unload_hooks(HookSpecs) ->
format(#server{name = Name, hookspec = Hooks}) ->
lists:flatten(
io_lib:format("name=~s, hooks=~0p, active=true", [Name, Hooks])).
io_lib:format("name=~ts, hooks=~0p, active=true", [Name, Hooks])).
%%--------------------------------------------------------------------
%% APIs

View File

@ -663,7 +663,7 @@ handle_incoming(Packet, State = #state{
}) ->
Ctx = ChannMod:info(ctx, Channel),
ok = inc_incoming_stats(Ctx, FrameMod, Packet),
?LOG(debug, "RECV ~s", [FrameMod:format(Packet)]),
?LOG(debug, "RECV ~ts", [FrameMod:format(Packet)]),
with_channel(handle_in, [Packet], State).
%%--------------------------------------------------------------------
@ -715,12 +715,12 @@ serialize_and_inc_stats_fun(#state{
Ctx = ChannMod:info(ctx, Channel),
fun(Packet) ->
case FrameMod:serialize_pkt(Packet, Serialize) of
<<>> -> ?LOG(warning, "~s is discarded due to the frame is too large!",
<<>> -> ?LOG(warning, "~ts is discarded due to the frame is too large!",
[FrameMod:format(Packet)]),
ok = emqx_gateway_ctx:metrics_inc(Ctx, 'delivery.dropped.too_large'),
ok = emqx_gateway_ctx:metrics_inc(Ctx, 'delivery.dropped'),
<<>>;
Data -> ?LOG(debug, "SEND ~s", [FrameMod:format(Packet)]),
Data -> ?LOG(debug, "SEND ~ts", [FrameMod:format(Packet)]),
ok = inc_outgoing_stats(Ctx, FrameMod, Packet),
Data
end

View File

@ -331,7 +331,7 @@ auth_connect(_Input, Channel = #channel{ctx = Ctx,
{ok, NClientInfo} ->
{ok, Channel#channel{clientinfo = NClientInfo}};
{error, Reason} ->
?LOG(warning, "Client ~s (Username: '~s') login failed for ~0p",
?LOG(warning, "Client ~ts (Username: '~ts') login failed for ~0p",
[ClientId, Username, Reason]),
{error, Reason}
end.
@ -473,7 +473,7 @@ process_connection({open, Req}, Result, Channel, Iter) ->
{ok, _Input, NChannel} ->
process_connect(ensure_connected(NChannel), Req, Result, Iter);
{error, ReasonCode, NChannel} ->
ErrMsg = io_lib:format("Login Failed: ~s", [ReasonCode]),
ErrMsg = io_lib:format("Login Failed: ~ts", [ReasonCode]),
Payload = erlang:list_to_binary(lists:flatten(ErrMsg)),
iter(Iter,
reply({error, bad_request}, Payload, Req, Result),

View File

@ -67,7 +67,7 @@ on_gateway_update(Config, Gateway, GwState = #{ctx := Ctx}) ->
on_gateway_load(Gateway#{config => Config}, Ctx)
catch
Class : Reason : Stk ->
logger:error("Failed to update ~s; "
logger:error("Failed to update ~ts; "
"reason: {~0p, ~0p} stacktrace: ~0p",
[GwName, Class, Reason, Stk]),
{error, {Class, Reason}}
@ -89,11 +89,11 @@ start_listener(GwName, Ctx, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) of
{ok, Pid} ->
?ULOG("Gateway ~s:~s:~s on ~s started.~n",
?ULOG("Gateway ~ts:~ts:~ts on ~ts started.~n",
[GwName, Type, LisName, ListenOnStr]),
Pid;
{error, Reason} ->
?ELOG("Failed to start gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to start gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason]),
throw({badconf, Reason})
end.
@ -118,10 +118,10 @@ stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
StopRet = stop_listener(GwName, Type, LisName, ListenOn, SocketOpts, Cfg),
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case StopRet of
ok -> ?ULOG("Gateway ~s:~s:~s on ~s stopped.~n",
ok -> ?ULOG("Gateway ~ts:~ts:~ts on ~ts stopped.~n",
[GwName, Type, LisName, ListenOnStr]);
{error, Reason} ->
?ELOG("Failed to stop gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to stop gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason])
end,
StopRet.

View File

@ -109,7 +109,7 @@ clients_insta(get, #{ bindings := #{name := Name0,
[ClientInfo] ->
{200, ClientInfo};
[ClientInfo | _More] ->
?LOG(warning, "More than one client info was returned on ~s",
?LOG(warning, "More than one client info was returned on ~ts",
[ClientId]),
{200, ClientInfo};
[] ->

View File

@ -51,10 +51,10 @@ gateway_type_searching() ->
reg(Mod) ->
try
Mod:reg(),
?LOG(info, "Register ~s gateway application successfully!", [Mod])
?LOG(info, "Register ~ts gateway application successfully!", [Mod])
catch
Class : Reason : Stk ->
?LOG(error, "Failed to register ~s gateway application: {~p, ~p}\n"
?LOG(error, "Failed to register ~ts gateway application: {~p, ~p}\n"
"Stacktrace: ~0p",
[Mod, Class, Reason, Stk])
end.
@ -67,14 +67,14 @@ load_gateway_by_default([]) ->
load_gateway_by_default([{Type, Confs}|More]) ->
case emqx_gateway_registry:lookup(Type) of
undefined ->
?LOG(error, "Skip to load ~s gateway, because it is not registered",
?LOG(error, "Skip to load ~ts gateway, because it is not registered",
[Type]);
_ ->
case emqx_gateway:load(Type, Confs) of
{ok, _} ->
?LOG(debug, "Load ~s gateway successfully!", [Type]);
?LOG(debug, "Load ~ts gateway successfully!", [Type]);
{error, Reason} ->
?LOG(error, "Failed to load ~s gateway: ~0p", [Type, Reason])
?LOG(error, "Failed to load ~ts gateway: ~0p", [Type, Reason])
end
end,
load_gateway_by_default(More).

View File

@ -53,7 +53,7 @@ gateway(["list"]) ->
lists:foreach(fun(#{name := Name} = Gateway) ->
%% TODO: More infos: listeners?, connected?
Status = maps:get(status, Gateway, stopped),
print("Gateway(name=~s, status=~s)~n", [Name, Status])
print("Gateway(name=~ts, status=~ts)~n", [Name, Status])
end, emqx_gateway:list());
gateway(["lookup", Name]) ->
@ -123,7 +123,7 @@ gateway(_) ->
'gateway-registry'(["list"]) ->
lists:foreach(
fun({Name, #{cbkmod := CbMod}}) ->
print("Registered Name: ~s, Callback Module: ~s~n", [Name, CbMod])
print("Registered Name: ~ts, Callback Module: ~ts~n", [Name, CbMod])
end,
emqx_gateway_registry:list());
@ -229,10 +229,10 @@ print_record({client, {_, Infos, Stats}}) ->
connected_at => ConnectedAt
},
print("Client(~s, username=~s, peername=~s, "
"clean_start=~s, keepalive=~w, "
print("Client(~ts, username=~ts, peername=~ts, "
"clean_start=~ts, keepalive=~w, "
"subscriptions=~w, delivered_msgs=~w, "
"connected=~s, created_at=~w, connected_at=~w)~n",
"connected=~ts, created_at=~w, connected_at=~w)~n",
[format(K, maps:get(K, Info)) || K <- InfoKeys]).
print(S) -> emqx_ctl:print(S).
@ -243,7 +243,7 @@ format(_, undefined) ->
format(peername, {IPAddr, Port}) ->
IPStr = emqx_mgmt_util:ntoa(IPAddr),
io_lib:format("~s:~p", [IPStr, Port]);
io_lib:format("~ts:~p", [IPStr, Port]);
format(_, Val) ->
Val.

View File

@ -103,7 +103,7 @@ init([Gateway, Ctx, _GwDscrptr]) ->
},
case maps:get(enable, Config, true) of
false ->
?LOG(info, "Skipp to start ~s gateway due to disabled", [GwName]),
?LOG(info, "Skipp to start ~ts gateway due to disabled", [GwName]),
{ok, State};
true ->
case cb_gateway_load(State) of
@ -266,13 +266,13 @@ do_create_authn_chain(ChainName, AuthConf) ->
case emqx_authentication:create_authenticator(ChainName, AuthConf) of
{ok, _} -> ok;
{error, Reason} ->
?LOG(error, "Failed to create authenticator chain ~s, "
?LOG(error, "Failed to create authenticator chain ~ts, "
"reason: ~p, config: ~p",
[ChainName, Reason, AuthConf]),
throw({badauth, Reason})
end;
{error, Reason} ->
?LOG(error, "Falied to create authn chain ~s, reason ~p",
?LOG(error, "Falied to create authn chain ~ts, reason ~p",
[ChainName, Reason]),
throw({badauth, Reason})
end.
@ -293,7 +293,7 @@ do_deinit_authn(Names) ->
ok -> ok;
{error, {not_found, _}} -> ok;
{error, Reason} ->
?LOG(error, "Failed to clean authentication chain: ~s, "
?LOG(error, "Failed to clean authentication chain: ~ts, "
"reason: ~p", [ChainName, Reason])
end
end, Names).
@ -388,7 +388,7 @@ cb_gateway_load(State = #state{name = GwName,
end
catch
Class : Reason1 : Stk ->
?LOG(error, "Failed to load ~s gateway (~0p, ~0p) "
?LOG(error, "Failed to load ~ts gateway (~0p, ~0p) "
"crashed: {~p, ~p}, stacktrace: ~0p",
[GwName, Gateway, Ctx,
Class, Reason1, Stk]),
@ -413,7 +413,7 @@ cb_gateway_update(Config,
end
catch
Class : Reason1 : Stk ->
?LOG(error, "Failed to update ~s gateway to config: ~0p crashed: "
?LOG(error, "Failed to update ~ts gateway to config: ~0p crashed: "
"{~p, ~p}, stacktrace: ~0p",
[GwName, Config, Class, Reason1, Stk]),
{error, {Class, Reason1, Stk}}

View File

@ -112,9 +112,9 @@ apply(F, A2) when is_function(F),
format_listenon(Port) when is_integer(Port) ->
io_lib:format("0.0.0.0:~w", [Port]);
format_listenon({Addr, Port}) when is_list(Addr) ->
io_lib:format("~s:~w", [Addr, Port]);
io_lib:format("~ts:~w", [Addr, Port]);
format_listenon({Addr, Port}) when is_tuple(Addr) ->
io_lib:format("~s:~w", [inet:ntoa(Addr), Port]).
io_lib:format("~ts:~w", [inet:ntoa(Addr), Port]).
parse_listenon(Port) when is_integer(Port) ->
Port;

View File

@ -291,17 +291,17 @@ handle_call({auth, ClientInfo0, Password}, _From,
SessFun
) of
{ok, _Session} ->
?LOG(debug, "Client ~s (Username: '~s') authorized successfully!",
?LOG(debug, "Client ~ts (Username: '~ts') authorized successfully!",
[ClientId, Username]),
{reply, ok, [{event, connected}],
ensure_connected(Channel1#channel{clientinfo = NClientInfo})};
{error, Reason} ->
?LOG(warning, "Client ~s (Username: '~s') open session failed for ~0p",
?LOG(warning, "Client ~ts (Username: '~ts') open session failed for ~0p",
[ClientId, Username, Reason]),
{reply, {error, ?RESP_PERMISSION_DENY, Reason}, Channel}
end;
{error, Reason} ->
?LOG(warning, "Client ~s (Username: '~s') login failed for ~0p",
?LOG(warning, "Client ~ts (Username: '~ts') login failed for ~0p",
[ClientId, Username, Reason]),
{reply, {error, ?RESP_PERMISSION_DENY, Reason}, Channel}
end;

View File

@ -60,7 +60,7 @@ start_grpc_server(GwName, Options = #{bind := ListenOn}) ->
[{ssl_options, SslOpts}]
end,
_ = grpc:start_server(GwName, ListenOn, Services, SvrOptions),
?ULOG("Start ~s gRPC server on ~p successfully.~n", [GwName, ListenOn]).
?ULOG("Start ~ts gRPC server on ~p successfully.~n", [GwName, ListenOn]).
start_grpc_client_channel(_GwType, undefined) ->
undefined;
@ -71,7 +71,7 @@ start_grpc_client_channel(GwName, Options = #{address := UriStr}) ->
Port = maps:get(port, UriMap),
SvrAddr = lists:flatten(
io_lib:format(
"~s://~s:~w", [Scheme, Host, Port])
"~ts://~ts:~w", [Scheme, Host, Port])
),
ClientOpts = case Scheme of
"https" ->
@ -118,7 +118,7 @@ on_gateway_update(Config, Gateway, GwState = #{ctx := Ctx}) ->
on_gateway_load(Gateway#{config => Config}, Ctx)
catch
Class : Reason : Stk ->
logger:error("Failed to update ~s; "
logger:error("Failed to update ~ts; "
"reason: {~0p, ~0p} stacktrace: ~0p",
[GwName, Class, Reason, Stk]),
{error, {Class, Reason}}
@ -143,11 +143,11 @@ start_listener(GwName, Ctx, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) of
{ok, Pid} ->
?ULOG("Gateway ~s:~s:~s on ~s started.~n",
?ULOG("Gateway ~ts:~ts:~ts on ~ts started.~n",
[GwName, Type, LisName, ListenOnStr]),
Pid;
{error, Reason} ->
?ELOG("Failed to start gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to start gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason]),
throw({badconf, Reason})
end.
@ -198,10 +198,10 @@ stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
StopRet = stop_listener(GwName, Type, LisName, ListenOn, SocketOpts, Cfg),
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case StopRet of
ok -> ?ULOG("Gateway ~s:~s:~s on ~s stopped.~n",
ok -> ?ULOG("Gateway ~ts:~ts:~ts on ~ts stopped.~n",
[GwName, Type, LisName, ListenOnStr]);
{error, Reason} ->
?ELOG("Failed to stop gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to stop gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason])
end,
StopRet.

View File

@ -249,7 +249,7 @@ do_connect(Req, Result, Channel, Iter) ->
iter(Iter, maps:merge(Result, NewResult), NChannel)
end;
{error, ReasonCode, NChannel} ->
ErrMsg = io_lib:format("Login Failed: ~s", [ReasonCode]),
ErrMsg = io_lib:format("Login Failed: ~ts", [ReasonCode]),
Payload = erlang:list_to_binary(lists:flatten(ErrMsg)),
iter(Iter,
reply({error, bad_request}, Payload, Req, Result),
@ -320,7 +320,7 @@ auth_connect(_Input, Channel = #channel{ctx = Ctx,
{ok, Channel#channel{clientinfo = NClientInfo,
with_context = with_context(Ctx, ClientInfo)}};
{error, Reason} ->
?LOG(warning, "Client ~s (Username: '~s') login failed for ~0p",
?LOG(warning, "Client ~ts (Username: '~ts') login failed for ~0p",
[ClientId, Username, Reason]),
{error, Reason}
end.

View File

@ -68,7 +68,7 @@ on_gateway_update(NewGateway, OldGateway, GwState = #{ctx := Ctx}) ->
on_gateway_load(NewGateway, Ctx)
catch
Class : Reason : Stk ->
logger:error("Failed to update ~s; "
logger:error("Failed to update ~ts; "
"reason: {~0p, ~0p} stacktrace: ~0p",
[GwName, Class, Reason, Stk]),
{error, {Class, Reason}}
@ -90,11 +90,11 @@ start_listener(GwName, Ctx, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) of
{ok, Pid} ->
?ULOG("Gateway ~s:~s:~s on ~s started.~n",
?ULOG("Gateway ~ts:~ts:~ts on ~ts started.~n",
[GwName, Type, LisName, ListenOnStr]),
Pid;
{error, Reason} ->
?ELOG("Failed to start gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to start gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason]),
throw({badconf, Reason})
end.
@ -130,10 +130,10 @@ stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
StopRet = stop_listener(GwName, Type, LisName, ListenOn, SocketOpts, Cfg),
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case StopRet of
ok -> ?ULOG("Gateway ~s:~s:~s on ~s stopped.~n",
ok -> ?ULOG("Gateway ~ts:~ts:~ts on ~ts stopped.~n",
[GwName, Type, LisName, ListenOnStr]);
{error, Reason} ->
?ELOG("Failed to stop gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to stop gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason])
end,
StopRet.

View File

@ -287,7 +287,7 @@ auth_connect(_Packet, Channel = #channel{ctx = Ctx,
{ok, NClientInfo} ->
{ok, Channel#channel{clientinfo = NClientInfo}};
{error, Reason} ->
?LOG(warning, "Client ~s (Username: '~s') login failed for ~0p",
?LOG(warning, "Client ~ts (Username: '~ts') login failed for ~0p",
[ClientId, Username, Reason]),
%% FIXME: ReasonCode?
{error, Reason}
@ -860,7 +860,7 @@ run_client_subs_hook({TopicId, TopicName, QoS},
case run_hooks(Ctx, 'client.subscribe',
[ClientInfo, #{}], TopicFilters) of
[] ->
?LOG(warning, "Skip to subscribe ~s, "
?LOG(warning, "Skip to subscribe ~ts, "
"due to 'client.subscribe' denied!", [TopicName]),
{error, ?SN_EXCEED_LIMITATION};
[{NTopicName, NSubOpts}|_] ->
@ -879,7 +879,7 @@ do_subscribe({TopicId, TopicName, SubOpts},
{ok, {TopicId, NTopicName, NSubOpts},
Channel#channel{session = NSession}};
{error, ?RC_QUOTA_EXCEEDED} ->
?LOG(warning, "Cannot subscribe ~s due to ~s.",
?LOG(warning, "Cannot subscribe ~ts due to ~ts.",
[TopicName, emqx_reason_codes:text(?RC_QUOTA_EXCEEDED)]),
{error, ?SN_EXCEED_LIMITATION}
end.

View File

@ -292,10 +292,10 @@ message_type(Type) ->
io_lib:format("Unknown Type ~p", [Type]).
format(?SN_PUBLISH_MSG(Flags, TopicId, MsgId, Data)) ->
io_lib:format("mqtt_sn_message SN_PUBLISH, ~s, TopicId=~w, MsgId=~w, Payload=~w",
io_lib:format("mqtt_sn_message SN_PUBLISH, ~ts, TopicId=~w, MsgId=~w, Payload=~w",
[format_flag(Flags), TopicId, MsgId, Data]);
format(?SN_PUBACK_MSG(Flags, MsgId, ReturnCode)) ->
io_lib:format("mqtt_sn_message SN_PUBACK, ~s, MsgId=~w, ReturnCode=~w",
io_lib:format("mqtt_sn_message SN_PUBACK, ~ts, MsgId=~w, ReturnCode=~w",
[format_flag(Flags), MsgId, ReturnCode]);
format(?SN_PUBREC_MSG(?SN_PUBCOMP, MsgId)) ->
io_lib:format("mqtt_sn_message SN_PUBCOMP, MsgId=~w", [MsgId]);
@ -304,13 +304,13 @@ format(?SN_PUBREC_MSG(?SN_PUBREC, MsgId)) ->
format(?SN_PUBREC_MSG(?SN_PUBREL, MsgId)) ->
io_lib:format("mqtt_sn_message SN_PUBREL, MsgId=~w", [MsgId]);
format(?SN_SUBSCRIBE_MSG(Flags, Msgid, Topic)) ->
io_lib:format("mqtt_sn_message SN_SUBSCRIBE, ~s, MsgId=~w, TopicId=~w",
io_lib:format("mqtt_sn_message SN_SUBSCRIBE, ~ts, MsgId=~w, TopicId=~w",
[format_flag(Flags), Msgid, Topic]);
format(?SN_SUBACK_MSG(Flags, TopicId, MsgId, ReturnCode)) ->
io_lib:format("mqtt_sn_message SN_SUBACK, ~s, MsgId=~w, TopicId=~w, ReturnCode=~w",
io_lib:format("mqtt_sn_message SN_SUBACK, ~ts, MsgId=~w, TopicId=~w, ReturnCode=~w",
[format_flag(Flags), MsgId, TopicId, ReturnCode]);
format(?SN_UNSUBSCRIBE_MSG(Flags, Msgid, Topic)) ->
io_lib:format("mqtt_sn_message SN_UNSUBSCRIBE, ~s, MsgId=~w, TopicId=~w",
io_lib:format("mqtt_sn_message SN_UNSUBSCRIBE, ~ts, MsgId=~w, TopicId=~w",
[format_flag(Flags), Msgid, Topic]);
format(?SN_UNSUBACK_MSG(MsgId)) ->
io_lib:format("mqtt_sn_message SN_UNSUBACK, MsgId=~w", [MsgId]);
@ -321,7 +321,7 @@ format(?SN_REGACK_MSG(TopicId, MsgId, ReturnCode)) ->
io_lib:format("mqtt_sn_message SN_REGACK, TopicId=~w, MsgId=~w, ReturnCode=~w",
[TopicId, MsgId, ReturnCode]);
format(#mqtt_sn_message{type = Type, variable = Var}) ->
io_lib:format("mqtt_sn_message type=~s, Var=~w", [emqx_sn_frame:message_type(Type), Var]).
io_lib:format("mqtt_sn_message type=~ts, Var=~w", [emqx_sn_frame:message_type(Type), Var]).
format_flag(#mqtt_sn_flags{dup = Dup, qos = QoS, retain = Retain, will = Will, clean_start = CleanStart, topic_id_type = TopicType}) ->
io_lib:format("mqtt_sn_flags{dup=~p, qos=~p, retain=~p, will=~p, clean_session=~p, topic_id_type=~p}",

View File

@ -86,7 +86,7 @@ on_gateway_update(Config, Gateway, GwState = #{ctx := Ctx}) ->
on_gateway_load(Gateway#{config => Config}, Ctx)
catch
Class : Reason : Stk ->
logger:error("Failed to update ~s; "
logger:error("Failed to update ~ts; "
"reason: {~0p, ~0p} stacktrace: ~0p",
[GwName, Class, Reason, Stk]),
{error, {Class, Reason}}
@ -108,11 +108,11 @@ start_listener(GwName, Ctx, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) of
{ok, Pid} ->
?ULOG("Gateway ~s:~s:~s on ~s started.~n",
?ULOG("Gateway ~ts:~ts:~ts on ~ts started.~n",
[GwName, Type, LisName, ListenOnStr]),
Pid;
{error, Reason} ->
?ELOG("Failed to start gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to start gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason]),
throw({badconf, Reason})
end.
@ -142,10 +142,10 @@ stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
StopRet = stop_listener(GwName, Type, LisName, ListenOn, SocketOpts, Cfg),
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case StopRet of
ok -> ?ULOG("Gateway ~s:~s:~s on ~s stopped.~n",
ok -> ?ULOG("Gateway ~ts:~ts:~ts on ~ts stopped.~n",
[GwName, Type, LisName, ListenOnStr]);
{error, Reason} ->
?ELOG("Failed to stop gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to stop gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason])
end,
StopRet.

View File

@ -280,7 +280,7 @@ auth_connect(_Packet, Channel = #channel{ctx = Ctx,
{ok, NClientInfo} ->
{ok, Channel#channel{clientinfo = NClientInfo}};
{error, Reason} ->
?LOG(warning, "Client ~s (Username: '~s') login failed for ~0p",
?LOG(warning, "Client ~ts (Username: '~ts') login failed for ~0p",
[ClientId, Username, Reason]),
{error, Reason}
end.
@ -352,7 +352,7 @@ handle_in(Packet = ?PACKET(?CMD_CONNECT), Channel) ->
{ok, _NPacket, NChannel} ->
process_connect(ensure_connected(NChannel));
{error, ReasonCode, NChannel} ->
ErrMsg = io_lib:format("Login Failed: ~s", [ReasonCode]),
ErrMsg = io_lib:format("Login Failed: ~ts", [ReasonCode]),
handle_out(connerr, {[], undefined, ErrMsg}, NChannel)
end;
@ -403,7 +403,7 @@ handle_in(?PACKET(?CMD_SUBSCRIBE, Headers),
handle_out(receipt, receipt_id(Headers), NChannel1)
end;
{error, ErrMsg, NChannel} ->
?LOG(error, "Failed to subscribe topic ~s, reason: ~s",
?LOG(error, "Failed to subscribe topic ~ts, reason: ~ts",
[Topic, ErrMsg]),
handle_out(error, {receipt_id(Headers), ErrMsg}, NChannel)
end;
@ -485,7 +485,7 @@ handle_in(?PACKET(?CMD_COMMIT, Headers), Channel) ->
maybe_outgoing_receipt(receipt_id(Headers), Outgoings, Chann1);
{error, Reason, Chann1} ->
%% FIXME: atomic for transaction ??
ErrMsg = io_lib:format("Execute transaction ~s falied: ~0p",
ErrMsg = io_lib:format("Execute transaction ~ts falied: ~0p",
[TxId, Reason]
),
handle_out(error, {receipt_id(Headers), ErrMsg}, Chann1)
@ -653,7 +653,7 @@ handle_call({subscribe, Topic, SubOpts}, _From,
NChannel1 = NChannel#channel{subscriptions = NSubs},
reply(ok, NChannel1);
{error, ErrMsg, NChannel} ->
?LOG(error, "Failed to subscribe topic ~s, reason: ~s",
?LOG(error, "Failed to subscribe topic ~ts, reason: ~ts",
[Topic, ErrMsg]),
reply({error, ErrMsg}, NChannel)
end
@ -829,7 +829,7 @@ handle_deliver(Delivers,
[Frame|Acc];
false ->
?LOG(error, "Dropped message ~0p due to not found "
"subscription id for ~s",
"subscription id for ~ts",
[Message, emqx_message:topic(Message)]),
metrics_inc('delivery.dropped', Channel),
metrics_inc('delivery.dropped.no_subid', Channel),

View File

@ -71,7 +71,7 @@ on_gateway_update(Config, Gateway, GwState = #{ctx := Ctx}) ->
on_gateway_load(Gateway#{config => Config}, Ctx)
catch
Class : Reason : Stk ->
logger:error("Failed to update ~s; "
logger:error("Failed to update ~ts; "
"reason: {~0p, ~0p} stacktrace: ~0p",
[GwName, Class, Reason, Stk]),
{error, {Class, Reason}}
@ -93,11 +93,11 @@ start_listener(GwName, Ctx, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case start_listener(GwName, Ctx, Type, LisName, ListenOn, SocketOpts, Cfg) of
{ok, Pid} ->
?ULOG("Gateway ~s:~s:~s on ~s started.~n",
?ULOG("Gateway ~ts:~ts:~ts on ~ts started.~n",
[GwName, Type, LisName, ListenOnStr]),
Pid;
{error, Reason} ->
?ELOG("Failed to start gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to start gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason]),
throw({badconf, Reason})
end.
@ -127,10 +127,10 @@ stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
StopRet = stop_listener(GwName, Type, LisName, ListenOn, SocketOpts, Cfg),
ListenOnStr = emqx_gateway_utils:format_listenon(ListenOn),
case StopRet of
ok -> ?ULOG("Gateway ~s:~s:~s on ~s stopped.~n",
ok -> ?ULOG("Gateway ~ts:~ts:~ts on ~ts stopped.~n",
[GwName, Type, LisName, ListenOnStr]);
{error, Reason} ->
?ELOG("Failed to stop gateway ~s:~s:~s on ~s: ~0p~n",
?ELOG("Failed to stop gateway ~ts:~ts:~ts on ~ts: ~0p~n",
[GwName, Type, LisName, ListenOnStr, Reason])
end,
StopRet.

View File

@ -74,7 +74,7 @@ t_connection(_Config) ->
%% heartbeat
HeartURI = ?MQTT_PREFIX ++ "/connection?clientid=client1&token=" ++ Token,
?LOGT("send heartbeat request:~s~n", [HeartURI]),
?LOGT("send heartbeat request:~ts~n", [HeartURI]),
{ok, changed, _} = er_coap_client:request(put, HeartURI),
disconnection(Channel, Token),
@ -140,7 +140,7 @@ t_subscribe(_Config) ->
URI = ?PS_PREFIX ++ TopicStr ++ "?clientid=client1&token=" ++ Token,
Req = make_req(get, Payload, [{observe, 0}]),
{ok, content, _} = do_request(Channel, URI, Req),
?LOGT("observer topic:~s~n", [Topic]),
?LOGT("observer topic:~ts~n", [Topic]),
timer:sleep(100),
[SubPid] = emqx:subscribers(Topic),
@ -172,7 +172,7 @@ t_un_subscribe(_Config) ->
Req = make_req(get, Payload, [{observe, 0}]),
{ok, content, _} = do_request(Channel, URI, Req),
?LOGT("observer topic:~s~n", [Topic]),
?LOGT("observer topic:~ts~n", [Topic]),
timer:sleep(100),
[SubPid] = emqx:subscribers(Topic),
@ -180,7 +180,7 @@ t_un_subscribe(_Config) ->
UnReq = make_req(get, Payload, [{observe, 1}]),
{ok, nocontent, _} = do_request(Channel, URI, UnReq),
?LOGT("un observer topic:~s~n", [Topic]),
?LOGT("un observer topic:~ts~n", [Topic]),
timer:sleep(100),
?assertEqual([], emqx:subscribers(Topic))
end,
@ -197,7 +197,7 @@ t_observe_wildcard(_Config) ->
URI = ?PS_PREFIX ++ TopicStr ++ "?clientid=client1&token=" ++ Token,
Req = make_req(get, Payload, [{observe, 0}]),
{ok, content, _} = do_request(Channel, URI, Req),
?LOGT("observer topic:~s~n", [Topic]),
?LOGT("observer topic:~ts~n", [Topic]),
timer:sleep(100),
[SubPid] = emqx:subscribers(Topic),
@ -244,7 +244,7 @@ do_request(Channel, URI, #coap_message{options = Opts} = Req) ->
{_, _, Path, Query} = er_coap_client:resolve_uri(URI),
Opts2 = [{uri_path, Path}, {uri_query, Query} | Opts],
Req2 = Req#coap_message{options = Opts2},
?LOGT("send request:~s~nReq:~p~n", [URI, Req2]),
?LOGT("send request:~ts~nReq:~p~n", [URI, Req2]),
{ok, _} = er_coap_channel:send(Channel, Req2),
with_response(Channel).

View File

@ -119,7 +119,7 @@ test_send_coap_request(UdpSock, Method, Content, Options, MsgId) ->
?LOGT("test udp socket send to ~p:~p, data=~p", [IpAddr, Port, RequestBinary]),
ok = gen_udp:send(UdpSock, IpAddr, Port, RequestBinary);
{SchemeDiff, ChIdDiff, _, _} ->
error(lists:flatten(io_lib:format("scheme ~s or ChId ~s does not match with socket", [SchemeDiff, ChIdDiff])))
error(lists:flatten(io_lib:format("scheme ~ts or ChId ~ts does not match with socket", [SchemeDiff, ChIdDiff])))
end.
test_recv_coap_response(UdpSock) ->

View File

@ -190,7 +190,7 @@ case01_register(Config) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
[],
MsgId),
@ -216,7 +216,7 @@ case01_register(Config) ->
MsgId3 = 52,
test_send_coap_request( UdpSock,
delete,
sprintf("coap://127.0.0.1:~b~s", [?PORT, join_path(Location, <<>>)]),
sprintf("coap://127.0.0.1:~b~ts", [?PORT, join_path(Location, <<>>)]),
#coap_content{payload = <<>>},
[],
MsgId3),
@ -235,7 +235,7 @@ case01_register_additional_opts(Config) ->
MsgId = 12,
SubTopic = list_to_binary("lwm2m/"++Epn++"/dn/#"),
AddOpts = "ep=~s&lt=345&lwm2m=1&apn=psmA.eDRX0.ctnb&cust_opt=shawn&im=123&ct=1.4&mt=mdm9620&mv=1.2",
AddOpts = "ep=~ts&lt=345&lwm2m=1&apn=psmA.eDRX0.ctnb&cust_opt=shawn&im=123&ct=1.4&mt=mdm9620&mv=1.2",
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?" ++ AddOpts, [?PORT, Epn]),
@ -264,7 +264,7 @@ case01_register_additional_opts(Config) ->
MsgId3 = 52,
test_send_coap_request( UdpSock,
delete,
sprintf("coap://127.0.0.1:~b~s", [?PORT, join_path(Location, <<>>)]),
sprintf("coap://127.0.0.1:~b~ts", [?PORT, join_path(Location, <<>>)]),
#coap_content{payload = <<>>},
[],
MsgId3),
@ -283,7 +283,7 @@ case01_register_incorrect_opts(Config) ->
MsgId = 12,
AddOpts = "ep=~s&lt=345&lwm2m=1&incorrect_opt",
AddOpts = "ep=~ts&lt=345&lwm2m=1&incorrect_opt",
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?" ++ AddOpts, [?PORT, Epn]),
@ -310,7 +310,7 @@ case01_register_report(Config) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
[],
MsgId),
@ -345,7 +345,7 @@ case01_register_report(Config) ->
MsgId3 = 52,
test_send_coap_request( UdpSock,
delete,
sprintf("coap://127.0.0.1:~b~s", [?PORT, join_path(Location, <<>>)]),
sprintf("coap://127.0.0.1:~b~ts", [?PORT, join_path(Location, <<>>)]),
#coap_content{payload = <<>>},
[],
MsgId3),
@ -369,7 +369,7 @@ case02_update_deregister(Config) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
[],
MsgId),
@ -398,7 +398,7 @@ case02_update_deregister(Config) ->
MsgId2 = 27,
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b~s?lt=789", [?PORT, join_path(Location, <<>>)]),
sprintf("coap://127.0.0.1:~b~ts?lt=789", [?PORT, join_path(Location, <<>>)]),
#coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>, </6>">>},
[],
MsgId2),
@ -424,7 +424,7 @@ case02_update_deregister(Config) ->
MsgId3 = 52,
test_send_coap_request( UdpSock,
delete,
sprintf("coap://127.0.0.1:~b~s", [?PORT, join_path(Location, <<>>)]),
sprintf("coap://127.0.0.1:~b~ts", [?PORT, join_path(Location, <<>>)]),
#coap_content{payload = <<>>},
[],
MsgId3),
@ -445,7 +445,7 @@ case03_register_wrong_version(Config) ->
SubTopic = list_to_binary("lwm2m/"++Epn++"/dn/#"),
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=8.3", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=8.3", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
[],
MsgId),
@ -466,7 +466,7 @@ case04_register_and_lifetime_timeout(Config) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=2&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=2&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
[],
MsgId),
@ -509,7 +509,7 @@ case05_register_wrong_epn(Config) ->
%% test_send_coap_request( UdpSock,
%% post,
%% sprintf("coap://127.0.0.1:~b/rd?ep=~s&lwm2m=1", [?PORT, Epn]),
%% sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lwm2m=1", [?PORT, Epn]),
%% #coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
%% [],
%% MsgId),
@ -532,7 +532,7 @@ case07_register_alternate_path_01(Config) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>,
payload = <<"</>;rt=\"oma.lwm2m\";ct=11543,</lwm2m/1/0>,</lwm2m/2/0>,</lwm2m/3/0>">>},
[],
@ -554,7 +554,7 @@ case07_register_alternate_path_02(Config) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>,
payload = <<"</lwm2m>;rt=\"oma.lwm2m\";ct=11543,</lwm2m/1/0>,</lwm2m/2/0>,</lwm2m/3/0>">>},
[],
@ -576,7 +576,7 @@ case08_reregister(Config) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>,
payload = <<"</lwm2m>;rt=\"oma.lwm2m\";ct=11543,</lwm2m/1/0>,</lwm2m/2/0>,</lwm2m/3/0>">>},
[],
@ -602,7 +602,7 @@ case08_reregister(Config) ->
%% the same lwm2mc client registers to server again
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>,
payload = <<"</lwm2m>;rt=\"oma.lwm2m\";ct=11543,</lwm2m/1/0>,</lwm2m/2/0>,</lwm2m/3/0>">>},
[],
@ -621,7 +621,7 @@ case10_read(Config) ->
%% step 1, device register ...
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>,
payload = <<"</lwm2m>;rt=\"oma.lwm2m\";ct=11543,</lwm2m/1/0>,</lwm2m/2/0>,</lwm2m/3/0>">>},
[],
@ -1605,7 +1605,7 @@ case60_observe(Config) ->
%% test_send_coap_request( UdpSock,
%% post,
%% sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1"++RegOptionWangYi, [?PORT, Epn]),
%% sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1"++RegOptionWangYi, [?PORT, Epn]),
%% #coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
%% [],
%% MsgId1),
@ -1671,7 +1671,7 @@ case60_observe(Config) ->
%% test_send_coap_request( UdpSock,
%% post,
%% sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1"++RegOptionWangYi, [?PORT, Epn]),
%% sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1"++RegOptionWangYi, [?PORT, Epn]),
%% #coap_content{content_format = <<"text/plain">>, payload = <<"</1>, </2>, </3>, </4>, </5>">>},
%% [],
%% MsgId1),
@ -1717,10 +1717,10 @@ case60_observe(Config) ->
%% ?assertEqual(ReadResult, test_recv_mqtt_response(RespTopic)).
case90_psm_mode(Config) ->
server_cache_mode(Config, "ep=~s&lt=345&lwm2m=1&apn=psmA.eDRX0.ctnb").
server_cache_mode(Config, "ep=~ts&lt=345&lwm2m=1&apn=psmA.eDRX0.ctnb").
case90_queue_mode(Config) ->
server_cache_mode(Config, "ep=~s&lt=345&lwm2m=1&b=UQ").
server_cache_mode(Config, "ep=~ts&lt=345&lwm2m=1&b=UQ").
server_cache_mode(Config, RegOption) ->
#{lwm2m := LwM2M} = Gateway = emqx:get_config([gateway]),
@ -1817,7 +1817,7 @@ device_update_1(UdpSock, Location) ->
MsgId2 = 27,
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b~s?lt=789", [?PORT, join_path(Location, <<>>)]),
sprintf("coap://127.0.0.1:~b~ts?lt=789", [?PORT, join_path(Location, <<>>)]),
#coap_content{payload = <<>>},
[],
MsgId2),
@ -1845,7 +1845,7 @@ test_send_coap_request(UdpSock, Method, Uri, Content, Options, MsgId) ->
?LOGT("test udp socket send to ~p:~p, data=~p", [IpAddr, Port, RequestBinary]),
ok = gen_udp:send(UdpSock, IpAddr, Port, RequestBinary);
{SchemeDiff, ChIdDiff, _, _} ->
error(lists:flatten(io_lib:format("scheme ~s or ChId ~s does not match with socket", [SchemeDiff, ChIdDiff])))
error(lists:flatten(io_lib:format("scheme ~ts or ChId ~ts does not match with socket", [SchemeDiff, ChIdDiff])))
end.
test_recv_coap_response(UdpSock) ->
@ -1916,7 +1916,7 @@ test_send_coap_notif(UdpSock, Host, Port, Content, ObSeq, Request) ->
std_register(UdpSock, Epn, ObjectList, MsgId1, RespTopic) ->
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=345&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=345&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>, payload = ObjectList},
[],
MsgId1),

View File

@ -108,7 +108,7 @@ t_lookup_cmd_read(Config) ->
%% step 1, device register ...
test_send_coap_request( UdpSock,
post,
sprintf("coap://127.0.0.1:~b/rd?ep=~s&lt=600&lwm2m=1", [?PORT, Epn]),
sprintf("coap://127.0.0.1:~b/rd?ep=~ts&lt=600&lwm2m=1", [?PORT, Epn]),
#coap_content{content_format = <<"text/plain">>,
payload = <<"</lwm2m>;rt=\"oma.lwm2m\";ct=11543,</lwm2m/1/0>,</lwm2m/2/0>,</lwm2m/3/0>">>},
[],
@ -192,9 +192,9 @@ t_lookup_cmd_discover(Config) ->
send_request(ClientId, Path, Action) ->
ApiPath = emqx_mgmt_api_test_util:api_path(["gateway/lwm2m", ClientId, "lookup_cmd"]),
Auth = emqx_mgmt_api_test_util:auth_header_(),
Query = io_lib:format("path=~s&action=~s", [Path, Action]),
Query = io_lib:format("path=~ts&action=~ts", [Path, Action]),
{ok, Response} = emqx_mgmt_api_test_util:request_api(get, ApiPath, Query, Auth),
?LOGT("rest api response:~s~n", [Response]),
?LOGT("rest api response:~ts~n", [Response]),
Response.
no_received_request(ClientId, Path, Action) ->

View File

@ -37,7 +37,7 @@ post_boot() ->
print_vsn() -> ok.
-else. % TEST
print_vsn() ->
?ULOG("~s ~s is running now!~n", [emqx_app:get_description(), emqx_app:get_release()]).
?ULOG("~ts ~ts is running now!~n", [emqx_app:get_description(), emqx_app:get_release()]).
-endif. % TEST

View File

@ -41,7 +41,7 @@ running_status(get, _Params) ->
false -> not_running;
{value, _Val} -> running
end,
Status = io_lib:format("Node ~s is ~s~nemqx is ~s", [node(), InternalStatus, AppStatus]),
Status = io_lib:format("Node ~ts is ~ts~nemqx is ~ts", [node(), InternalStatus, AppStatus]),
Body = list_to_binary(Status),
{200, #{<<"content-type">> => <<"text/plain">>}, Body}.

View File

@ -21,7 +21,7 @@
-include("emqx_mgmt.hrl").
-define(PRINT_CMD(Cmd, Descr), io:format("~-48s# ~s~n", [Cmd, Descr])).
-define(PRINT_CMD(Cmd, Descr), io:format("~-48s# ~ts~n", [Cmd, Descr])).
-export([load/0]).
@ -65,7 +65,7 @@ is_cmd(Fun) ->
status([]) ->
{InternalStatus, _ProvidedStatus} = init:get_status(),
emqx_ctl:print("Node ~p ~s is ~p~n", [node(), emqx_app:get_release(), InternalStatus]);
emqx_ctl:print("Node ~p ~ts is ~p~n", [node(), emqx_app:get_release(), InternalStatus]);
status(_) ->
emqx_ctl:usage("status", "Show broker status").
@ -74,7 +74,7 @@ status(_) ->
broker([]) ->
Funs = [sysdescr, version, datetime],
[emqx_ctl:print("~-10s: ~s~n", [Fun, emqx_sys:Fun()]) || Fun <- Funs],
[emqx_ctl:print("~-10s: ~ts~n", [Fun, emqx_sys:Fun()]) || Fun <- Funs],
emqx_ctl:print("~-10s: ~p~n", [uptime, emqx_sys:uptime()]);
broker(["stats"]) ->
@ -227,9 +227,9 @@ plugins(["list"]) ->
plugins(["load", Name]) ->
case emqx_plugins:load(list_to_atom(Name)) of
ok ->
emqx_ctl:print("Plugin ~s loaded successfully.~n", [Name]);
emqx_ctl:print("Plugin ~ts loaded successfully.~n", [Name]);
{error, Reason} ->
emqx_ctl:print("Load plugin ~s error: ~p.~n", [Name, Reason])
emqx_ctl:print("Load plugin ~ts error: ~p.~n", [Name, Reason])
end;
plugins(["unload", "emqx_management"])->
@ -238,9 +238,9 @@ plugins(["unload", "emqx_management"])->
plugins(["unload", Name]) ->
case emqx_plugins:unload(list_to_atom(Name)) of
ok ->
emqx_ctl:print("Plugin ~s unloaded successfully.~n", [Name]);
emqx_ctl:print("Plugin ~ts unloaded successfully.~n", [Name]);
{error, Reason} ->
emqx_ctl:print("Unload plugin ~s error: ~p.~n", [Name, Reason])
emqx_ctl:print("Unload plugin ~ts error: ~p.~n", [Name, Reason])
end;
plugins(["reload", Name]) ->
@ -248,13 +248,13 @@ plugins(["reload", Name]) ->
PluginName ->
case emqx_mgmt:reload_plugin(node(), PluginName) of
ok ->
emqx_ctl:print("Plugin ~s reloaded successfully.~n", [Name]);
emqx_ctl:print("Plugin ~ts reloaded successfully.~n", [Name]);
{error, Reason} ->
emqx_ctl:print("Reload plugin ~s error: ~p.~n", [Name, Reason])
emqx_ctl:print("Reload plugin ~ts error: ~p.~n", [Name, Reason])
end
catch
error:badarg ->
emqx_ctl:print("Reload plugin ~s error: The plugin doesn't exist.~n", [Name])
emqx_ctl:print("Reload plugin ~ts error: The plugin doesn't exist.~n", [Name])
end;
plugins(_) ->
@ -274,7 +274,7 @@ vm(["all"]) ->
[vm([Name]) || Name <- ["load", "memory", "process", "io", "ports"]];
vm(["load"]) ->
[emqx_ctl:print("cpu/~-20s: ~s~n", [L, V]) || {L, V} <- emqx_vm:loads()];
[emqx_ctl:print("cpu/~-20s: ~ts~n", [L, V]) || {L, V} <- emqx_vm:loads()];
vm(["memory"]) ->
[emqx_ctl:print("memory/~-17s: ~w~n", [Cat, Val]) || {Cat, Val} <- erlang:memory()];
@ -311,42 +311,42 @@ mnesia(_) ->
log(["set-level", Level]) ->
case emqx_logger:set_log_level(list_to_atom(Level)) of
ok -> emqx_ctl:print("~s~n", [Level]);
ok -> emqx_ctl:print("~ts~n", [Level]);
Error -> emqx_ctl:print("[error] set overall log level failed: ~p~n", [Error])
end;
log(["primary-level"]) ->
Level = emqx_logger:get_primary_log_level(),
emqx_ctl:print("~s~n", [Level]);
emqx_ctl:print("~ts~n", [Level]);
log(["primary-level", Level]) ->
_ = emqx_logger:set_primary_log_level(list_to_atom(Level)),
emqx_ctl:print("~s~n", [emqx_logger:get_primary_log_level()]);
emqx_ctl:print("~ts~n", [emqx_logger:get_primary_log_level()]);
log(["handlers", "list"]) ->
_ = [emqx_ctl:print("LogHandler(id=~s, level=~s, destination=~s, status=~s)~n", [Id, Level, Dst, Status])
_ = [emqx_ctl:print("LogHandler(id=~ts, level=~ts, destination=~ts, status=~ts)~n", [Id, Level, Dst, Status])
|| #{id := Id, level := Level, dst := Dst, status := Status} <- emqx_logger:get_log_handlers()],
ok;
log(["handlers", "start", HandlerId]) ->
case emqx_logger:start_log_handler(list_to_atom(HandlerId)) of
ok -> emqx_ctl:print("log handler ~s started~n", [HandlerId]);
ok -> emqx_ctl:print("log handler ~ts started~n", [HandlerId]);
{error, Reason} ->
emqx_ctl:print("[error] failed to start log handler ~s: ~p~n", [HandlerId, Reason])
emqx_ctl:print("[error] failed to start log handler ~ts: ~p~n", [HandlerId, Reason])
end;
log(["handlers", "stop", HandlerId]) ->
case emqx_logger:stop_log_handler(list_to_atom(HandlerId)) of
ok -> emqx_ctl:print("log handler ~s stopped~n", [HandlerId]);
ok -> emqx_ctl:print("log handler ~ts stopped~n", [HandlerId]);
{error, Reason} ->
emqx_ctl:print("[error] failed to stop log handler ~s: ~p~n", [HandlerId, Reason])
emqx_ctl:print("[error] failed to stop log handler ~ts: ~p~n", [HandlerId, Reason])
end;
log(["handlers", "set-level", HandlerId, Level]) ->
case emqx_logger:set_log_handler_level(list_to_atom(HandlerId), list_to_atom(Level)) of
ok ->
#{level := NewLevel} = emqx_logger:get_log_handler(list_to_atom(HandlerId)),
emqx_ctl:print("~s~n", [NewLevel]);
emqx_ctl:print("~ts~n", [NewLevel]);
{error, Error} ->
emqx_ctl:print("[error] ~p~n", [Error])
end;
@ -365,7 +365,7 @@ log(_) ->
trace(["list"]) ->
lists:foreach(fun({{Who, Name}, {Level, LogFile}}) ->
emqx_ctl:print("Trace(~s=~s, level=~s, destination=~p)~n", [Who, Name, Level, LogFile])
emqx_ctl:print("Trace(~ts=~ts, level=~ts, destination=~p)~n", [Who, Name, Level, LogFile])
end, emqx_tracer:lookup_traces());
trace(["stop", "client", ClientId]) ->
@ -396,17 +396,17 @@ trace(_) ->
trace_on(Who, Name, Level, LogFile) ->
case emqx_tracer:start_trace({Who, iolist_to_binary(Name)}, Level, LogFile) of
ok ->
emqx_ctl:print("trace ~s ~s successfully~n", [Who, Name]);
emqx_ctl:print("trace ~ts ~ts successfully~n", [Who, Name]);
{error, Error} ->
emqx_ctl:print("[error] trace ~s ~s: ~p~n", [Who, Name, Error])
emqx_ctl:print("[error] trace ~ts ~ts: ~p~n", [Who, Name, Error])
end.
trace_off(Who, Name) ->
case emqx_tracer:stop_trace({Who, iolist_to_binary(Name)}) of
ok ->
emqx_ctl:print("stop tracing ~s ~s successfully~n", [Who, Name]);
emqx_ctl:print("stop tracing ~ts ~ts successfully~n", [Who, Name]);
{error, Error} ->
emqx_ctl:print("[error] stop tracing ~s ~s: ~p~n", [Who, Name, Error])
emqx_ctl:print("[error] stop tracing ~ts ~ts: ~p~n", [Who, Name, Error])
end.
%%--------------------------------------------------------------------
@ -432,32 +432,32 @@ listeners([]) ->
{proxy_protocol, ProxyProtocol},
{running, Running}
] ++ CurrentConns ++ MaxConn,
emqx_ctl:print("~s~n", [ID]),
emqx_ctl:print("~ts~n", [ID]),
lists:foreach(fun indent_print/1, Info)
end, emqx_listeners:list());
listeners(["stop", ListenerId]) ->
case emqx_listeners:stop_listener(list_to_atom(ListenerId)) of
ok ->
emqx_ctl:print("Stop ~s listener successfully.~n", [ListenerId]);
emqx_ctl:print("Stop ~ts listener successfully.~n", [ListenerId]);
{error, Error} ->
emqx_ctl:print("Failed to stop ~s listener: ~0p~n", [ListenerId, Error])
emqx_ctl:print("Failed to stop ~ts listener: ~0p~n", [ListenerId, Error])
end;
listeners(["start", ListenerId]) ->
case emqx_listeners:start_listener(list_to_atom(ListenerId)) of
ok ->
emqx_ctl:print("Started ~s listener successfully.~n", [ListenerId]);
emqx_ctl:print("Started ~ts listener successfully.~n", [ListenerId]);
{error, Error} ->
emqx_ctl:print("Failed to start ~s listener: ~0p~n", [ListenerId, Error])
emqx_ctl:print("Failed to start ~ts listener: ~0p~n", [ListenerId, Error])
end;
listeners(["restart", ListenerId]) ->
case emqx_listeners:restart_listener(list_to_atom(ListenerId)) of
ok ->
emqx_ctl:print("Restarted ~s listener successfully.~n", [ListenerId]);
emqx_ctl:print("Restarted ~ts listener successfully.~n", [ListenerId]);
{error, Error} ->
emqx_ctl:print("Failed to restart ~s listener: ~0p~n", [ListenerId, Error])
emqx_ctl:print("Failed to restart ~ts listener: ~0p~n", [ListenerId, Error])
end;
listeners(_) ->
@ -473,9 +473,9 @@ listeners(_) ->
authz(["cache-clean", "node", Node]) ->
case emqx_mgmt:clean_authz_cache_all(erlang:list_to_existing_atom(Node)) of
ok ->
emqx_ctl:print("Authorization cache drain started on node ~s.~n", [Node]);
emqx_ctl:print("Authorization cache drain started on node ~ts.~n", [Node]);
{error, Reason} ->
emqx_ctl:print("Authorization drain failed on node ~s: ~0p.~n", [Node, Reason])
emqx_ctl:print("Authorization drain failed on node ~ts: ~0p.~n", [Node, Reason])
end;
authz(["cache-clean", "all"]) ->
@ -549,10 +549,10 @@ print({client, {ClientId, ChanPid}}) ->
false -> []
end,
Info1 = Info#{expiry_interval => maps:get(expiry_interval, Info) div 1000},
emqx_ctl:print("Client(~s, username=~s, peername=~s, "
"clean_start=~s, keepalive=~w, session_expiry_interval=~w, "
emqx_ctl:print("Client(~ts, username=~ts, peername=~ts, "
"clean_start=~ts, keepalive=~w, session_expiry_interval=~w, "
"subscriptions=~w, inflight=~w, awaiting_rel=~w, delivered_msgs=~w, enqueued_msgs=~w, dropped_msgs=~w, "
"connected=~s, created_at=~w, connected_at=~w" ++
"connected=~ts, created_at=~w, connected_at=~w" ++
case maps:is_key(disconnected_at, Info1) of
true -> ", disconnected_at=~w)~n";
false -> ")~n"
@ -560,23 +560,23 @@ print({client, {ClientId, ChanPid}}) ->
[format(K, maps:get(K, Info1)) || K <- InfoKeys]);
print({emqx_route, #route{topic = Topic, dest = {_, Node}}}) ->
emqx_ctl:print("~s -> ~s~n", [Topic, Node]);
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
print({emqx_route, #route{topic = Topic, dest = Node}}) ->
emqx_ctl:print("~s -> ~s~n", [Topic, Node]);
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
print(#plugin{name = Name, descr = Descr, active = Active}) ->
emqx_ctl:print("Plugin(~s, description=~s, active=~s)~n",
emqx_ctl:print("Plugin(~ts, description=~ts, active=~ts)~n",
[Name, Descr, Active]);
print({emqx_suboption, {{Pid, Topic}, Options}}) when is_pid(Pid) ->
emqx_ctl:print("~s -> ~s~n", [maps:get(subid, Options), Topic]).
emqx_ctl:print("~ts -> ~ts~n", [maps:get(subid, Options), Topic]).
format(_, undefined) ->
undefined;
format(peername, {IPAddr, Port}) ->
IPStr = emqx_mgmt_util:ntoa(IPAddr),
io_lib:format("~s:~p", [IPStr, Port]);
io_lib:format("~ts:~p", [IPStr, Port]);
format(_, Val) ->
Val.
@ -584,13 +584,13 @@ format(_, Val) ->
bin(S) -> iolist_to_binary(S).
indent_print({Key, {string, Val}}) ->
emqx_ctl:print(" ~-16s: ~s~n", [Key, Val]);
emqx_ctl:print(" ~-16s: ~ts~n", [Key, Val]);
indent_print({Key, Val}) ->
emqx_ctl:print(" ~-16s: ~w~n", [Key, Val]).
format_listen_on(Port) when is_integer(Port) ->
io_lib:format("0.0.0.0:~w", [Port]);
format_listen_on({Addr, Port}) when is_list(Addr) ->
io_lib:format("~s:~w", [Addr, Port]);
io_lib:format("~ts:~w", [Addr, Port]);
format_listen_on({Addr, Port}) when is_tuple(Addr) ->
io_lib:format("~s:~w", [inet:ntoa(Addr), Port]).
io_lib:format("~ts:~w", [inet:ntoa(Addr), Port]).

View File

@ -80,7 +80,7 @@ kmg(Byte) when Byte > ?KB ->
kmg(Byte) ->
Byte.
kmg(F, S) ->
iolist_to_binary(io_lib:format("~.2f~s", [F, S])).
iolist_to_binary(io_lib:format("~.2f~ts", [F, S])).
ntoa({0,0,0,0,0,16#ffff,AB,CD}) ->
inet_parse:ntoa({AB bsr 8, AB rem 256, CD bsr 8, CD rem 256});

View File

@ -136,7 +136,7 @@ data(get, _Request) ->
% TelemetryData = get_telemetry_data(),
% case emqx_json:safe_encode(TelemetryData, [pretty]) of
% {ok, Bin} ->
% emqx_ctl:print("~s~n", [Bin]);
% emqx_ctl:print("~ts~n", [Bin]);
% {error, _Reason} ->
% emqx_ctl:print("Failed to get telemetry data")
% end;

View File

@ -101,7 +101,7 @@ do_save_file(FileName, Content, Dir) ->
ok ->
ensure_str(FullFilename);
{error, Reason} ->
logger:error("failed_to_save_ssl_file ~s: ~0p", [FullFilename, Reason]),
logger:error("failed_to_save_ssl_file ~ts: ~0p", [FullFilename, Reason]),
error({"failed_to_save_ssl_file", FullFilename, Reason})
end.

View File

@ -172,7 +172,7 @@ do_create(InstId, ResourceType, Config) ->
_ = do_health_check(InstId),
{ok, force_lookup(InstId)};
{error, Reason} ->
logger:error("start ~s resource ~s failed: ~p", [ResourceType, InstId, Reason]),
logger:error("start ~ts resource ~ts failed: ~p", [ResourceType, InstId, Reason]),
{error, Reason}
end
end.

View File

@ -56,7 +56,7 @@ len(string) -> fun string:length/1;
len(_Type) -> fun(Val) -> Val end.
err_limit({Type, {Op, Expected}, {got, Got}}) ->
io_lib:format("Expect the ~s value ~s ~p but got: ~p", [Type, Op, Expected, Got]).
io_lib:format("Expect the ~ts value ~ts ~p but got: ~p", [Type, Op, Expected, Got]).
return(true, _) -> ok;
return(false, Error) ->

View File

@ -288,7 +288,7 @@ store_retained(Context, #message{topic = Topic, payload = Payload} = Msg) ->
Mod = get_backend_module(),
Mod:store_retained(Context, Msg);
_ ->
?ERROR("Cannot retain message(topic=~s, payload_size=~p) for payload is too big!",
?ERROR("Cannot retain message(topic=~ts, payload_size=~p) for payload is too big!",
[Topic, iolist_size(Payload)])
end.
@ -441,17 +441,17 @@ get_backend_module() ->
true ->
Backend
end,
erlang:list_to_existing_atom(io_lib:format("~s_~s", [?APP, ModName])).
erlang:list_to_existing_atom(io_lib:format("~ts_~ts", [?APP, ModName])).
create_resource(Context, #{type := built_in_database} = Cfg) ->
emqx_retainer_mnesia:create_resource(Cfg),
Context;
create_resource(Context, #{type := DB} = Config) ->
ResourceID = erlang:iolist_to_binary([io_lib:format("~s_~s", [?APP, DB])]),
ResourceID = erlang:iolist_to_binary([io_lib:format("~ts_~ts", [?APP, DB])]),
case emqx_resource:create(
ResourceID,
list_to_existing_atom(io_lib:format("~s_~s", [emqx_connector, DB])),
list_to_existing_atom(io_lib:format("~ts_~ts", [emqx_connector, DB])),
Config) of
{ok, already_created} ->
Context#{resource_id => ResourceID};

View File

@ -89,7 +89,7 @@ store_retained(_, Msg =#message{topic = Topic}) ->
write);
[] ->
?LOG(error,
"Cannot retain message(topic=~s) for table is full!",
"Cannot retain message(topic=~ts) for table is full!",
[Topic]),
ok
end

View File

@ -29,7 +29,7 @@
, rule_test/2
]).
-define(ERR_NO_RULE(ID), list_to_binary(io_lib:format("Rule ~s Not Found", [(ID)]))).
-define(ERR_NO_RULE(ID), list_to_binary(io_lib:format("Rule ~ts Not Found", [(ID)]))).
-define(ERR_BADARGS(REASON),
begin
R0 = err_msg(REASON),

View File

@ -914,9 +914,9 @@ map_path(Key) ->
function_literal(Fun, []) when is_atom(Fun) ->
atom_to_list(Fun) ++ "()";
function_literal(Fun, [FArg | Args]) when is_atom(Fun), is_list(Args) ->
WithFirstArg = io_lib:format("~s(~0p", [atom_to_list(Fun), FArg]),
WithFirstArg = io_lib:format("~ts(~0p", [atom_to_list(Fun), FArg]),
lists:foldl(fun(Arg, Literal) ->
io_lib:format("~s, ~0p", [Literal, Arg])
io_lib:format("~ts, ~0p", [Literal, Arg])
end, WithFirstArg, Args) ++ ")";
function_literal(Fun, Args) ->
{invalid_func, {Fun, Args}}.

View File

@ -25,7 +25,7 @@
-spec console(map(), map(), map()) -> any().
console(Selected, #{metadata := #{rule_id := RuleId}} = Envs, _Args) ->
?ULOG("[rule output] ~s~n"
?ULOG("[rule output] ~ts~n"
"\tOutput Data: ~p~n"
"\tEnvs: ~p~n", [RuleId, Selected, Envs]).

View File

@ -38,7 +38,7 @@
-type collection() :: {alias(), [term()]}.
-define(ephemeral_alias(TYPE, NAME),
iolist_to_binary(io_lib:format("_v_~s_~p_~p", [TYPE, NAME, erlang:system_time()]))).
iolist_to_binary(io_lib:format("_v_~ts_~p_~p", [TYPE, NAME, erlang:system_time()]))).
-define(ActionMaxRetry, 3).

View File

@ -423,9 +423,9 @@ t_concat(_) ->
?assertEqual(<<>>, apply_func(concat, [<<"">>, <<"">>])).
t_sprintf(_) ->
?assertEqual(<<"Hello Shawn!">>, apply_func(sprintf, [<<"Hello ~s!">>, <<"Shawn">>])),
?assertEqual(<<"Name: ABC, Count: 2">>, apply_func(sprintf, [<<"Name: ~s, Count: ~p">>, <<"ABC">>, 2])),
?assertEqual(<<"Name: ABC, Count: 2, Status: {ok,running}">>, apply_func(sprintf, [<<"Name: ~s, Count: ~p, Status: ~p">>, <<"ABC">>, 2, {ok, running}])).
?assertEqual(<<"Hello Shawn!">>, apply_func(sprintf, [<<"Hello ~ts!">>, <<"Shawn">>])),
?assertEqual(<<"Name: ABC, Count: 2">>, apply_func(sprintf, [<<"Name: ~ts, Count: ~p">>, <<"ABC">>, 2])),
?assertEqual(<<"Name: ABC, Count: 2, Status: {ok,running}">>, apply_func(sprintf, [<<"Name: ~ts, Count: ~p, Status: ~p">>, <<"ABC">>, 2, {ok, running}])).
t_pad(_) ->
?assertEqual(<<"abc ">>, apply_func(pad, [<<"abc">>, 5])),