From 3aa173d29e011081840018d367d00660e66b5eb8 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Mon, 11 Aug 2014 18:17:41 +0100 Subject: Remove a ton of special-case error_logger invocations --- src/rabbit.erl | 21 ++++++++++----------- src/rabbit_misc.erl | 6 +++--- src/rabbit_mnesia.erl | 16 ++++++++-------- src/rabbit_networking.erl | 4 ++-- src/rabbit_plugins.erl | 2 +- src/rabbit_upgrade.erl | 6 ++---- 6 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/rabbit.erl b/src/rabbit.erl index 76888b5d..9ce9ec84 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -259,7 +259,7 @@ maybe_hipe_compile() -> warn_if_hipe_compilation_failed(true) -> ok; warn_if_hipe_compilation_failed(false) -> - error_logger:warning_msg( + rabbit_log:warning( "Not HiPE compiling: HiPE not found in this Erlang installation.~n"). %% HiPE compilation happens before we have log handlers and can take a @@ -495,9 +495,9 @@ start(normal, []) -> case erts_version_check() of ok -> {ok, Vsn} = application:get_key(rabbit, vsn), - error_logger:info_msg("Starting RabbitMQ ~s on Erlang ~s~n~s~n~s~n", - [Vsn, erlang:system_info(otp_release), - ?COPYRIGHT_MESSAGE, ?INFORMATION_MESSAGE]), + rabbit_log:info("Starting RabbitMQ ~s on Erlang ~s~n~s~n~s~n", + [Vsn, erlang:system_info(otp_release), + ?COPYRIGHT_MESSAGE, ?INFORMATION_MESSAGE]), {ok, SupPid} = rabbit_sup:start_link(), true = register(rabbit, self()), print_banner(), @@ -766,7 +766,7 @@ log_broker_started(Plugins) -> fun() -> PluginList = iolist_to_binary([rabbit_misc:format(" * ~s~n", [P]) || P <- Plugins]), - error_logger:info_msg( + rabbit_log:info( "Server startup complete; ~b plugins started.~n~s", [length(Plugins), PluginList]), io:format(" completed with ~p plugins.~n", [length(Plugins)]) @@ -815,18 +815,18 @@ log_banner() -> {K, V} -> Format(K, V) end || S <- Settings]), - error_logger:info_msg("~s", [Banner]). + rabbit_log:info("~s", [Banner]). warn_if_kernel_config_dubious() -> case erlang:system_info(kernel_poll) of true -> ok; - false -> error_logger:warning_msg( + false -> rabbit_log:warning( "Kernel poll (epoll, kqueue, etc) is disabled. Throughput " "and CPU utilization may worsen.~n") end, AsyncThreads = erlang:system_info(thread_pool_size), case AsyncThreads < ?ASYNC_THREADS_WARNING_THRESHOLD of - true -> error_logger:warning_msg( + true -> rabbit_log:warning( "Erlang VM is running with ~b I/O threads, " "file I/O performance may worsen~n", [AsyncThreads]); false -> ok @@ -836,9 +836,8 @@ warn_if_kernel_config_dubious() -> {ok, Val} -> Val end, case proplists:get_value(nodelay, IDCOpts, false) of - false -> error_logger:warning_msg( - "Nagle's algorithm is enabled for sockets, " - "network I/O latency will be higher~n"); + false -> rabbit_log:warning("Nagle's algorithm is enabled for sockets, " + "network I/O latency will be higher~n"); true -> ok end. diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index a5cd1bdd..7ff88f04 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -656,10 +656,10 @@ with_local_io(Fun) -> end. %% Log an info message on the local node using the standard logger. -%% Use this if rabbit isn't running and the call didn't originate on -%% the local node (e.g. rabbitmqctl calls). +%% Use this if the call didn't originate on the local node (e.g. +%% rabbitmqctl calls). local_info_msg(Format, Args) -> - with_local_io(fun () -> error_logger:info_msg(Format, Args) end). + with_local_io(fun () -> rabbit_log:info(Format, Args) end). unfold(Fun, Init) -> unfold(Fun, [], Init). diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 630d9853..d06bae71 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -116,7 +116,7 @@ init_from_config() -> true -> disc; false -> ram end}, - error_logger:warning_msg( + rabbit_log:warning( "Converting legacy 'cluster_nodes' configuration~n ~w~n" "to~n ~w.~n~n" "Please update the configuration to the new format " @@ -619,10 +619,10 @@ schema_ok_or_move() -> {error, Reason} -> %% NB: we cannot use rabbit_log here since it may not have been %% started yet - error_logger:warning_msg("schema integrity check failed: ~p~n" - "moving database to backup location " - "and recreating schema from scratch~n", - [Reason]), + rabbit_log:warning("schema integrity check failed: ~p~n" + "moving database to backup location " + "and recreating schema from scratch~n", + [Reason]), ok = move_db(), ok = create_schema() end. @@ -648,8 +648,8 @@ move_db() -> ok -> %% NB: we cannot use rabbit_log here since it may not have %% been started yet - error_logger:warning_msg("moved database from ~s to ~s~n", - [MnesiaDir, BackupDir]), + rabbit_log:warning("moved database from ~s to ~s~n", + [MnesiaDir, BackupDir]), ok; {error, Reason} -> throw({error, {cannot_backup_mnesia, MnesiaDir, BackupDir, Reason}}) @@ -695,7 +695,7 @@ leave_cluster(Node) -> end. wait_for(Condition) -> - error_logger:info_msg("Waiting for ~p...~n", [Condition]), + rabbit_log:info("Waiting for ~p...~n", [Condition]), timer:sleep(1000). start_mnesia(CheckConsistency) -> diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl index 96448f32..4e92bf39 100644 --- a/src/rabbit_networking.erl +++ b/src/rabbit_networking.erl @@ -208,7 +208,7 @@ tcp_listener_addresses({Host, Port, Family0}) [{IPAddress, Port, Family} || {IPAddress, Family} <- getaddr(Host, Family0)]; tcp_listener_addresses({_Host, Port, _Family0}) -> - error_logger:error_msg("invalid port ~p - not 0..65535~n", [Port]), + rabbit_log:error("invalid port ~p - not 0..65535~n", [Port]), throw({error, {invalid_port, Port}}). tcp_listener_addresses_auto(Port) -> @@ -395,7 +395,7 @@ gethostaddr(Host, Family) -> end. host_lookup_error(Host, Reason) -> - error_logger:error_msg("invalid host ~p - ~p~n", [Host, Reason]), + rabbit_log:error("invalid host ~p - ~p~n", [Host, Reason]), throw({error, {invalid_host, Host, Reason}}). resolve_family({_,_,_,_}, auto) -> inet; diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index 9acaa1d4..04db5d5d 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -97,7 +97,7 @@ list(PluginsDir) -> [plugin_info(PluginsDir, Plug) || Plug <- EZs ++ FreeApps]), case Problems of [] -> ok; - _ -> error_logger:warning_msg( + _ -> rabbit_log:warning( "Problem reading some plugins: ~p~n", [Problems]) end, ensure_dependencies(Plugins). diff --git a/src/rabbit_upgrade.erl b/src/rabbit_upgrade.erl index 8ab35a89..72bf7855 100644 --- a/src/rabbit_upgrade.erl +++ b/src/rabbit_upgrade.erl @@ -190,7 +190,7 @@ die(Msg, Args) -> %% We don't throw or exit here since that gets thrown %% straight out into do_boot, generating an erl_crash.dump %% and displaying any error message in a confusing way. - error_logger:error_msg(Msg, Args), + rabbit_log:error(Msg, Args), Str = rabbit_misc:format( "~n~n****~n~n" ++ Msg ++ "~n~n****~n~n~n", Args), io:format(Str), @@ -281,6 +281,4 @@ node_type_legacy() -> false -> ram end. -%% NB: we cannot use rabbit_log here since it may not have been -%% started yet -info(Msg, Args) -> error_logger:info_msg(Msg, Args). +info(Msg, Args) -> rabbit_log:info(Msg, Args). -- cgit v1.2.1