summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-02-27 16:54:59 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-02-27 16:54:59 +0000
commit2c6eae506dc887e61aa13ce377353eee10f01354 (patch)
treede834c0d634b41f5ed4481608f126d600af4e809
parentea04c853e986643efafd1ee988d79808a98031d3 (diff)
downloadrabbitmq-server-bug26042.tar.gz
Make mirrored queue logging configurable.bug26042
-rw-r--r--src/rabbit_mirror_queue_master.erl4
-rw-r--r--src/rabbit_mirror_queue_misc.erl25
-rw-r--r--src/rabbit_mirror_queue_slave.erl9
3 files changed, 22 insertions, 16 deletions
diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl
index b272c64f..7bf6bd4a 100644
--- a/src/rabbit_mirror_queue_master.erl
+++ b/src/rabbit_mirror_queue_master.erl
@@ -139,8 +139,8 @@ sync_mirrors(HandleInfo, EmitStats,
backing_queue = BQ,
backing_queue_state = BQS }) ->
Log = fun (Fmt, Params) ->
- rabbit_log:info("Synchronising ~s: " ++ Fmt ++ "~n",
- [rabbit_misc:rs(QName) | Params])
+ rabbit_mirror_queue_misc:log_info(
+ QName, "Synchronising ~s: " ++ Fmt ++ "~n", Params)
end,
Log("~p messages to synchronise", [BQ:len(BQS)]),
{ok, #amqqueue{slave_pids = SPids}} = rabbit_amqqueue:lookup(QName),
diff --git a/src/rabbit_mirror_queue_misc.erl b/src/rabbit_mirror_queue_misc.erl
index 4f77009c..4e9d5aef 100644
--- a/src/rabbit_mirror_queue_misc.erl
+++ b/src/rabbit_mirror_queue_misc.erl
@@ -20,7 +20,7 @@
-export([remove_from_queue/3, on_node_up/0, add_mirrors/3,
report_deaths/4, store_updated_slaves/1, suggested_queue_nodes/1,
is_mirrored/1, update_mirrors/2, validate_policy/1,
- maybe_auto_sync/1]).
+ maybe_auto_sync/1, log_info/3, log_warning/3]).
%% for testing only
-export([module/1]).
@@ -56,6 +56,8 @@
-spec(update_mirrors/2 ::
(rabbit_types:amqqueue(), rabbit_types:amqqueue()) -> 'ok').
-spec(maybe_auto_sync/1 :: (rabbit_types:amqqueue()) -> 'ok').
+-spec(log_info/3 :: (rabbit_amqqueue:name(), string(), [any()]) -> 'ok').
+-spec(log_warning/3 :: (rabbit_amqqueue:name(), string(), [any()]) -> 'ok').
-endif.
@@ -156,9 +158,8 @@ drop_mirror(QName, MirrorNode) ->
[QPid] when SPids =:= [] ->
{error, cannot_drop_only_mirror};
[Pid] ->
- rabbit_log:info(
- "Dropping queue mirror on node ~p for ~s~n",
- [MirrorNode, rabbit_misc:rs(Name)]),
+ log_info(Name, "Dropping queue mirror on node ~p~n",
+ [MirrorNode]),
exit(Pid, {shutdown, dropped}),
{ok, dropped}
end;
@@ -192,23 +193,29 @@ start_child(Name, MirrorNode, Q, SyncMode) ->
fun () ->
{ok, SPid} = rabbit_mirror_queue_slave_sup:start_child(
MirrorNode, [Q]),
- rabbit_log:info("Adding mirror of ~s on node ~p: ~p~n",
- [rabbit_misc:rs(Name), MirrorNode, SPid]),
+ log_info(Name, "Adding mirror on node ~p: ~p~n",
+ [MirrorNode, SPid]),
rabbit_mirror_queue_slave:go(SPid, SyncMode)
end).
report_deaths(_MirrorPid, _IsMaster, _QueueName, []) ->
ok;
report_deaths(MirrorPid, IsMaster, QueueName, DeadPids) ->
- rabbit_log:info("Mirrored-queue (~s): ~s ~s saw deaths of mirrors ~s~n",
- [rabbit_misc:rs(QueueName),
- case IsMaster of
+ log_info(QueueName, "~s ~s saw deaths of mirrors ~s~n",
+ [case IsMaster of
true -> "Master";
false -> "Slave"
end,
rabbit_misc:pid_to_string(MirrorPid),
[[rabbit_misc:pid_to_string(P), $ ] || P <- DeadPids]]).
+log_info (QName, Fmt, Args) -> log(info, QName, Fmt, Args).
+log_warning(QName, Fmt, Args) -> log(warning, QName, Fmt, Args).
+
+log(Level, QName, Fmt, Args) ->
+ rabbit_log:log(mirroring, Level, "Mirrored ~s: " ++ Fmt,
+ [rabbit_misc:rs(QName) | Args]).
+
store_updated_slaves(Q = #amqqueue{slave_pids = SPids,
sync_slave_pids = SSPids}) ->
%% TODO now that we clear sync_slave_pids in rabbit_durable_queue,
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl
index 1f31b5c8..37d2e5b6 100644
--- a/src/rabbit_mirror_queue_slave.erl
+++ b/src/rabbit_mirror_queue_slave.erl
@@ -136,9 +136,8 @@ handle_go(Q = #amqqueue{name = QName}) ->
rabbit_mirror_queue_misc:maybe_auto_sync(Q1),
{ok, State};
{stale, StalePid} ->
- rabbit_log:warning("Detected stale HA master while adding "
- "mirror of ~s: ~p~n",
- [rabbit_misc:rs(QName), StalePid]),
+ rabbit_mirror_queue_misc:log_warning(
+ QName, "Detected stale HA master: ~p~n", [StalePid]),
gm:leave(GM),
{error, {stale_master_pid, StalePid}};
duplicate_live_master ->
@@ -526,8 +525,8 @@ promote_me(From, #state { q = Q = #amqqueue { name = QName },
msg_id_ack = MA,
msg_id_status = MS,
known_senders = KS }) ->
- rabbit_log:info("Mirrored-queue (~s): Promoting slave ~s to master~n",
- [rabbit_misc:rs(QName), rabbit_misc:pid_to_string(self())]),
+ rabbit_mirror_queue_misc:log_info(QName, "Promoting slave ~s to master~n",
+ [rabbit_misc:pid_to_string(self())]),
Q1 = Q #amqqueue { pid = self() },
{ok, CPid} = rabbit_mirror_queue_coordinator:start_link(
Q1, GM, rabbit_mirror_queue_master:sender_death_fun(),