Skip to content

Commit 450814c

Browse files
committed
[skip ci] Remove rabbit_log_shovel, use LOG_ macros directly
1 parent dd28838 commit 450814c

8 files changed

+52
-145
lines changed

deps/rabbitmq_shovel/src/rabbit_amqp10_shovel.erl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
-import(rabbit_misc, [pget/2, pget/3]).
3737
-import(rabbit_data_coercion, [to_binary/1]).
3838

39-
-define(INFO(Text, Args), rabbit_log_shovel:info(Text, Args)).
39+
-include_lib("kernel/include/logger.hrl").
40+
4041
-define(LINK_CREDIT_TIMEOUT, 20_000).
4142

4243
-type state() :: rabbit_shovel_behaviour:state().
@@ -194,7 +195,7 @@ handle_source({amqp10_event, {connection, Conn, opened}},
194195
handle_source({amqp10_event, {connection, Conn, {closed, Why}}},
195196
#{source := #{current := #{conn := Conn}},
196197
name := Name}) ->
197-
?INFO("Shovel ~ts source connection closed. Reason: ~tp", [Name, Why]),
198+
?LOG_INFO("Shovel ~ts source connection closed. Reason: ~tp", [Name, Why]),
198199
{stop, {inbound_conn_closed, Why}};
199200
handle_source({amqp10_event, {session, Sess, begun}},
200201
State = #{source := #{current := #{session := Sess}}}) ->
@@ -231,7 +232,7 @@ handle_dest({amqp10_disposition, {Result, Tag}},
231232
{#{Tag := IncomingTag}, rejected} ->
232233
{1, rabbit_shovel_behaviour:nack(IncomingTag, false, State1)};
233234
_ -> % not found - this should ideally not happen
234-
rabbit_log_shovel:warning("Shovel ~ts amqp10 destination disposition tag not found: ~tp",
235+
?LOG_WARNING("Shovel ~ts amqp10 destination disposition tag not found: ~tp",
235236
[Name, Tag]),
236237
{0, State1}
237238
end,
@@ -242,7 +243,7 @@ handle_dest({amqp10_event, {connection, Conn, opened}},
242243
handle_dest({amqp10_event, {connection, Conn, {closed, Why}}},
243244
#{name := Name,
244245
dest := #{current := #{conn := Conn}}}) ->
245-
?INFO("Shovel ~ts destination connection closed. Reason: ~tp", [Name, Why]),
246+
?LOG_INFO("Shovel ~ts destination connection closed. Reason: ~tp", [Name, Why]),
246247
{stop, {outbound_conn_died, Why}};
247248
handle_dest({amqp10_event, {session, Sess, begun}},
248249
State = #{dest := #{current := #{session := Sess}}}) ->

deps/rabbitmq_shovel/src/rabbit_log_shovel.erl

Lines changed: 0 additions & 108 deletions
This file was deleted.

deps/rabbitmq_shovel/src/rabbit_shovel_behaviour.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
incr_forwarded/1
3535
]).
3636

37+
-include_lib("kernel/include/logger.hrl").
38+
3739
-type tag() :: non_neg_integer().
3840
-type uri() :: string() | binary().
3941
-type ack_mode() :: 'no_ack' | 'on_confirm' | 'on_publish'.
@@ -189,7 +191,7 @@ decr_remaining(N, State = #{source := #{remaining := M} = Src,
189191
case M > N of
190192
true -> State#{source => Src#{remaining => M - N}};
191193
false ->
192-
rabbit_log_shovel:info("shutting down Shovel '~ts', no messages left to transfer", [Name]),
193-
rabbit_log_shovel:debug("shutting down Shovel '~ts', no messages left to transfer. Shovel state: ~tp", [Name, State]),
194+
?LOG_INFO("shutting down Shovel '~ts', no messages left to transfer", [Name]),
195+
?LOG_DEBUG("shutting down Shovel '~ts', no messages left to transfer. Shovel state: ~tp", [Name, State]),
194196
exit({shutdown, autodelete})
195197
end.

deps/rabbitmq_shovel/src/rabbit_shovel_dyn_worker_sup.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
-include_lib("rabbit_common/include/rabbit.hrl").
1616
-include("rabbit_shovel.hrl").
1717
-include_lib("kernel/include/logger.hrl").
18+
-include_lib("logging.hrl").
1819
-define(SUPERVISOR, ?MODULE).
1920

2021
start_link(Name, Config) ->
@@ -35,6 +36,7 @@ maybe_start_link(_, Name, Config) ->
3536
%%----------------------------------------------------------------------------
3637

3738
init([Name, Config0]) ->
39+
logger:set_process_metadata(#{domain => ?RMQLOG_DOMAIN_SHOVEL}),
3840
Config = rabbit_data_coercion:to_proplist(Config0),
3941
Delay = pget(<<"reconnect-delay">>, Config, ?DEFAULT_RECONNECT_DELAY),
4042
case Name of

deps/rabbitmq_shovel/src/rabbit_shovel_dyn_worker_sup_sup.erl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
-import(rabbit_misc, [pget/2]).
1515
-import(rabbit_data_coercion, [to_map/1, to_list/1]).
1616

17+
-include_lib("kernel/include/logger.hrl").
18+
-include_lib("logging.hrl").
1719
-include_lib("rabbit_common/include/rabbit.hrl").
1820
-define(SUPERVISOR, ?MODULE).
1921

@@ -37,10 +39,10 @@ adjust(Name, Def) ->
3739
start_child(Name, Def).
3840

3941
start_child({VHost, ShovelName} = Name, Def) ->
40-
rabbit_log_shovel:debug("Asked to start a dynamic Shovel named '~ts' in virtual host '~ts'", [ShovelName, VHost]),
42+
?LOG_DEBUG("Asked to start a dynamic Shovel named '~ts' in virtual host '~ts'", [ShovelName, VHost]),
4143
LockId = rabbit_shovel_locks:lock(Name),
4244
cleanup_specs(),
43-
rabbit_log_shovel:debug("Starting a mirrored supervisor named '~ts' in virtual host '~ts'", [ShovelName, VHost]),
45+
?LOG_DEBUG("Starting a mirrored supervisor named '~ts' in virtual host '~ts'", [ShovelName, VHost]),
4446
case child_exists(Name)
4547
orelse mirrored_supervisor:start_child(
4648
?SUPERVISOR,
@@ -68,7 +70,7 @@ child_exists(Name) ->
6870
mirrored_supervisor:which_children(?SUPERVISOR)).
6971

7072
stop_child({VHost, ShovelName} = Name) ->
71-
rabbit_log_shovel:debug("Asked to stop a dynamic Shovel named '~ts' in virtual host '~ts'", [ShovelName, VHost]),
73+
?LOG_DEBUG("Asked to stop a dynamic Shovel named '~ts' in virtual host '~ts'", [ShovelName, VHost]),
7274
LockId = rabbit_shovel_locks:lock(Name),
7375
case get({shovel_worker_autodelete, Name}) of
7476
true -> ok; %% [1]
@@ -136,6 +138,7 @@ cleanup_specs() ->
136138
%%----------------------------------------------------------------------------
137139

138140
init([]) ->
141+
logger:set_process_metadata(#{domain => ?RMQLOG_DOMAIN_SHOVEL}),
139142
{ok, {{one_for_one, 3, 10}, []}}.
140143

141144
id({VHost, ShovelName} = Name)

deps/rabbitmq_shovel/src/rabbit_shovel_status.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
2626
terminate/2, code_change/3]).
2727

28+
-include_lib("kernel/include/logger.hrl").
29+
-include("logging.hrl").
30+
2831
-define(SERVER, ?MODULE).
2932
-define(ETS_NAME, ?MODULE).
3033
-define(CHECK_FREQUENCY, 60000).
@@ -113,6 +116,7 @@ get_status_table() ->
113116
gen_server:call(?SERVER, get_status_table).
114117

115118
init([]) ->
119+
logger:set_process_metadata(#{domain => ?RMQLOG_DOMAIN_SHOVEL}),
116120
?ETS_NAME = ets:new(?ETS_NAME,
117121
[named_table, {keypos, #entry.name}, private]),
118122
{ok, ensure_timer(#state{})}.
@@ -185,7 +189,7 @@ handle_info(check, State) ->
185189
rabbit_shovel_dyn_worker_sup_sup:cleanup_specs()
186190
catch
187191
C:E ->
188-
rabbit_log_shovel:warning("Recurring shovel spec clean up failed with ~p:~p", [C, E])
192+
?LOG_WARNING("Recurring shovel spec clean up failed with ~p:~p", [C, E])
189193
end,
190194
{noreply, ensure_timer(State)};
191195
handle_info(_Info, State) ->

deps/rabbitmq_shovel/src/rabbit_shovel_util.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ restart_shovel(VHost, Name) ->
8989
not_found ->
9090
{error, not_found};
9191
_Obj ->
92-
rabbit_log_shovel:info("Shovel '~ts' in virtual host '~ts' will be restarted", [Name, VHost]),
92+
?LOG_INFO("Shovel '~ts' in virtual host '~ts' will be restarted", [Name, VHost]),
9393
ok = rabbit_shovel_dyn_worker_sup_sup:stop_child({VHost, Name}),
9494
{ok, _} = rabbit_shovel_dyn_worker_sup_sup:start_link(),
9595
ok

0 commit comments

Comments
 (0)