fix(emqx): Do not io:format when testing
This commit is contained in:
parent
25e0e121e5
commit
7667b65710
|
@ -74,8 +74,13 @@ print_otp_version_warning() ->
|
|||
print_banner() ->
|
||||
io:format("Starting ~s on node ~s~n", [?APP, node()]).
|
||||
|
||||
-ifndef(TEST).
|
||||
print_vsn() ->
|
||||
io:format("~s ~s is running now!~n", [get_description(), get_release()]).
|
||||
-else.
|
||||
print_vsn() ->
|
||||
ok.
|
||||
-endif.
|
||||
|
||||
get_description() ->
|
||||
{ok, Descr0} = application:get_key(?APP, description),
|
||||
|
|
|
@ -106,14 +106,21 @@ format_listen_on(ListenOn) -> format(ListenOn).
|
|||
start_listener(#{proto := Proto, name := Name, listen_on := ListenOn, opts := Options}) ->
|
||||
ID = identifier(Proto, Name),
|
||||
case start_listener(Proto, ListenOn, Options) of
|
||||
{ok, _} -> io:format("Start ~s listener on ~s successfully.~n",
|
||||
[ID, format(ListenOn)]);
|
||||
{ok, _} ->
|
||||
console_print("Start ~s listener on ~s successfully.~n", [ID, format(ListenOn)]);
|
||||
{error, Reason} ->
|
||||
io:format(standard_error, "Failed to start mqtt listener ~s on ~s: ~0p~n",
|
||||
[ID, format(ListenOn), Reason]),
|
||||
error(Reason)
|
||||
end.
|
||||
|
||||
-ifndef(TEST).
|
||||
console_print(Fmt, Args) ->
|
||||
io:format(Fmt, Args).
|
||||
-else.
|
||||
console_print(_Fmt, _Args) -> ok.
|
||||
-endif.
|
||||
|
||||
%% Start MQTT/TCP listener
|
||||
-spec(start_listener(esockd:proto(), esockd:listen_on(), [esockd:option()])
|
||||
-> {ok, pid()} | {error, term()}).
|
||||
|
|
Loading…
Reference in New Issue