summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-09-06 14:03:12 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-09-06 14:03:12 +0100
commitf80913f5e98aaba0f3e5e74031b39fbee21b5012 (patch)
tree8d36b15956e5fb6e3984f69d1fb68a46de1a7766
parent66c176cf8931359667f0893027a234c38af88564 (diff)
downloadrabbitmq-server-f80913f5e98aaba0f3e5e74031b39fbee21b5012.tar.gz
refactor
Two with_local_ios in rabbit_mnesia were unneeded. Huh. We only need to use with_local_io/1 when we use error_logger; the most common case is error_logger:info_msg/2, so we now have a helper function.
-rw-r--r--src/rabbit.erl8
-rw-r--r--src/rabbit_misc.erl7
-rw-r--r--src/rabbit_mnesia.erl31
3 files changed, 17 insertions, 29 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 6a0363cf..7592afec 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -231,8 +231,7 @@ stop_and_halt() ->
try
stop()
after
- rabbit_misc:with_local_io(
- fun () -> error_logger:info_msg("Halting Erlang VM~n") end),
+ rabbit_misc:local_info_msg("Halting Erlang VM~n", []),
init:stop()
end,
ok.
@@ -258,11 +257,8 @@ environment() ->
K =/= default_pass]).
rotate_logs(BinarySuffix) ->
- rabbit_misc:with_local_io(
- fun () -> error_logger:info_msg("Rotating logs with suffix '~s'~n",
- [BinarySuffix])
- end),
Suffix = binary_to_list(BinarySuffix),
+ rabbit_misc:local_info_msg("Rotating logs with suffix '~s'~n", [Suffix]),
log_rotation_result(rotate_logs(log_location(kernel),
Suffix,
rabbit_error_logger_file_h),
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index ae28722a..251b3646 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -42,7 +42,7 @@
-export([dirty_read_all/1, dirty_foreach_key/2, dirty_dump_log/1]).
-export([read_term_file/1, write_term_file/2, write_file/2, write_file/3]).
-export([append_file/2, ensure_parent_dirs_exist/1]).
--export([format_stderr/2, with_local_io/1]).
+-export([format_stderr/2, with_local_io/1, local_info_msg/2]).
-export([start_applications/1, stop_applications/1]).
-export([unfold/2, ceil/1, queue_fold/3]).
-export([sort_field_table/1]).
@@ -167,6 +167,7 @@
-spec(ensure_parent_dirs_exist/1 :: (string()) -> 'ok').
-spec(format_stderr/2 :: (string(), [any()]) -> 'ok').
-spec(with_local_io/1 :: (fun (() -> A)) -> A).
+-spec(local_info_msg/2 :: (string(), [any()]) -> 'ok').
-spec(start_applications/1 :: ([atom()]) -> 'ok').
-spec(stop_applications/1 :: ([atom()]) -> 'ok').
-spec(unfold/2 :: (fun ((A) -> ({'true', B, A} | 'false')), A) -> {[B], A}).
@@ -619,6 +620,10 @@ with_local_io(Fun) ->
group_leader(GL, self())
end.
+%% Log an info message on the local node using the standard logger.
+local_info_msg(Format, Args) ->
+ with_local_io(fun () -> error_logger:info_msg(Format, Args) end).
+
manage_applications(Iterate, Do, Undo, SkipError, ErrorTag, Apps) ->
Iterate(fun (App, Acc) ->
case Do(App) of
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl
index 913029de..0c81a771 100644
--- a/src/rabbit_mnesia.erl
+++ b/src/rabbit_mnesia.erl
@@ -119,13 +119,10 @@ force_cluster(ClusterNodes) ->
%% node. If Force is false, only connections to online nodes are
%% allowed.
cluster(ClusterNodes, Force) ->
- rabbit_misc:with_local_io(
- fun () -> error_logger:info_msg("Clustering with ~p~s~n",
- [ClusterNodes, if Force -> " forcefully";
- true -> ""
- end])
- end),
-
+ rabbit_misc:local_info_msg("Clustering with ~p~s~n",
+ [ClusterNodes, if Force -> " forcefully";
+ true -> ""
+ end]),
ensure_mnesia_not_running(),
ensure_mnesia_dir(),
@@ -723,13 +720,9 @@ wait_for_tables(TableNames) ->
end.
reset(Force) ->
- rabbit_misc:with_local_io(
- fun () ->
- error_logger:info_msg("Resetting Rabbit~s~n",
- [if Force -> " forcefully";
- true -> ""
- end])
- end),
+ rabbit_misc:local_info_msg("Resetting Rabbit~s~n", [if Force -> " forcefully";
+ true -> ""
+ end]),
ensure_mnesia_not_running(),
case not Force andalso is_clustered() andalso
is_only_disc_node(node(), false)
@@ -790,19 +783,13 @@ wait_for(Condition) ->
on_node_up(Node) ->
case is_only_disc_node(Node, true) of
- true -> rabbit_misc:with_local_io(
- fun () -> rabbit_log:info("cluster contains disc "
- "nodes again~n")
- end);
+ true -> rabbit_log:info("cluster contains disc nodes again~n");
false -> ok
end.
on_node_down(Node) ->
case is_only_disc_node(Node, true) of
- true -> rabbit_misc:with_local_io(
- fun () -> rabbit_log:info("only running disc node "
- "went down~n")
- end);
+ true -> rabbit_log:info("only running disc node went down~n");
false -> ok
end.