diff --git a/src/emqx_app.erl b/src/emqx_app.erl index ca6ce1073..2a89f0da1 100644 --- a/src/emqx_app.erl +++ b/src/emqx_app.erl @@ -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), diff --git a/src/emqx_listeners.erl b/src/emqx_listeners.erl index 270a66085..01ee753c4 100644 --- a/src/emqx_listeners.erl +++ b/src/emqx_listeners.erl @@ -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()}).