summaryrefslogtreecommitdiff
path: root/src/rabbit_control.erl
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-03 13:39:31 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-08-03 13:39:31 +0100
commita92021dd7c1d79f6b273c3704b47e7c8e6b84358 (patch)
tree3cb135819c98ced33b4a9dc9da36bbb67d2f9e00 /src/rabbit_control.erl
parent6ea01578cabe462c32dda4479b40785e1a593230 (diff)
downloadrabbitmq-server-a92021dd7c1d79f6b273c3704b47e7c8e6b84358.tar.gz
abstract out with_local_io/1
Because it will be needed whenever a rabbitmqctl command causes the logger to print anything.
Diffstat (limited to 'src/rabbit_control.erl')
-rw-r--r--src/rabbit_control.erl27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index bb42efb6..4bc25998 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -17,7 +17,7 @@
-module(rabbit_control).
-include("rabbit.hrl").
--export([start/0, stop/0, action/5, diagnostics/1, log_anytime/2]).
+-export([start/0, stop/0, action/5, diagnostics/1, log_action/3]).
-define(RPC_TIMEOUT, infinity).
-define(WAIT_FOR_VM_ATTEMPTS, 5).
@@ -51,7 +51,7 @@
-> 'ok').
-spec(diagnostics/1 :: (node()) -> [{string(), [any()]}]).
-spec(usage/0 :: () -> no_return()).
--spec(log_anytime/2 :: (string(), [term()]) -> ok).
+-spec(log_action/3 :: (node(), string(), [term()]) -> ok).
-endif.
@@ -74,9 +74,7 @@ start() ->
Command = list_to_atom(Command0),
Quiet = proplists:get_bool(?QUIET_OPT, Opts1),
Node = proplists:get_value(?NODE_OPT, Opts1),
- rpc_call(Node, rabbit_control, log_anytime,
- ["~p executing~nrabbitmqctl ~p ~p~n",
- [node(), Command0, mask_args(Command0, Args)]]),
+ rpc_call(Node, rabbit_control, log_action, [node(), Command0, Args]),
Inform = case Quiet of
true -> fun (_Format, _Args1) -> ok end;
false -> fun (Format, Args1) ->
@@ -113,14 +111,6 @@ start() ->
fmt_stderr(Format, Args) -> rabbit_misc:format_stderr(Format ++ "~n", Args).
-%% Log an info item on a remote node regardless of whether rabbit is
-%% running there or not: first change the group leader to that of the
-%% remote node, then use the standard error logger, because rabbit's
-%% might not be running.
-log_anytime(Format, Args) ->
- group_leader(whereis(user), self()),
- error_logger:info_msg(Format, Args).
-
print_report(Node, {Descr, Module, InfoFun, KeysFun}) ->
io:format("~s:~n", [Descr]),
print_report0(Node, {Module, InfoFun, KeysFun}, []).
@@ -487,10 +477,17 @@ quit(Status) ->
{win32, _} -> init:stop(Status)
end.
+log_action(Node, Command, Args) ->
+ rabbit_misc:with_local_io(
+ fun () ->
+ error_logger:info_msg("~p executing~nrabbitmqctl ~p ~p~n",
+ [Node, Command, mask_args(Command, Args)])
+ end).
+
%% Mask passwords and other sensitive info before logging.
-mask_args("add_user", [Name, Password | Args]) ->
+mask_args("add_user", [Name, _Password | Args]) ->
[Name, "****" | Args];
-mask_args("change_password", [Name, Password | Args]) ->
+mask_args("change_password", [Name, _Password | Args]) ->
[Name, "****" | Args];
mask_args(_, Args) ->
Args.