1010-include_lib (" rabbit/include/amqqueue.hrl" ).
1111-include_lib (" amqp_client/include/amqp_client.hrl" ).
1212-include (" rabbit_federation.hrl" ).
13+ -include_lib (" kernel/include/logger.hrl" ).
1314
1415% % real
1516-export ([start_conn_ch /5 , disposable_channel_call /2 , disposable_channel_call /3 ,
1617 disposable_connection_call /3 , ensure_connection_closed /1 ,
1718 log_terminate /4 , unacked_new /0 , ack /3 , nack /3 , forward /9 ,
1819 handle_downstream_down /3 , handle_upstream_down /3 ,
19- get_connection_name /2 , log_debug /3 , log_info /3 , log_warning /3 ,
20- log_error /3 ]).
20+ get_connection_name /2 ]).
2121
2222% % temp
2323-export ([connection_error /6 ]).
@@ -55,10 +55,9 @@ start_conn_ch(Fun, OUpstream, OUParams,
5555 process_flag (trap_exit , true ),
5656 try
5757 R = Fun (Conn , Ch , DConn , DCh ),
58- log_info (
59- XorQName , " connected to ~ts " ,
60- [rabbit_federation_upstream :params_to_string (
61- UParams )]),
58+ ? LOG_INFO (" Federation ~ts connected to ~ts " ,
59+ [rabbit_misc :rs (XorQName ),
60+ rabbit_federation_upstream :params_to_string (UParams )]),
6261 Name = pget (name , amqp_connection :info (DConn , [name ])),
6362 rabbit_federation_status :report (
6463 OUpstream , OUParams , XorQName , {running , Name }),
@@ -130,45 +129,44 @@ connection_error(remote_start, {{shutdown, {server_initiated_close, Code, Messag
130129 Upstream , UParams , XorQName , State ) ->
131130 rabbit_federation_status :report (
132131 Upstream , UParams , XorQName , clean_reason (E )),
133- log_warning (XorQName ,
134- " did not connect to ~ts . Server has closed the connection due to an error, code: ~tp , "
132+ ? LOG_WARNING (" Federation ~ts did not connect to ~ts . Server has closed the connection due to an error, code: ~tp , "
135133 " message: ~ts " ,
136- [rabbit_federation_upstream :params_to_string (UParams ),
134+ [rabbit_misc : rs ( XorQName ), rabbit_federation_upstream :params_to_string (UParams ),
137135 Code , Message ]),
138136 {stop , {shutdown , restart }, State };
139137
140138connection_error (remote_start , E , Upstream , UParams , XorQName , State ) ->
141139 rabbit_federation_status :report (
142140 Upstream , UParams , XorQName , clean_reason (E )),
143- log_warning ( XorQName , " did not connect to ~ts . Reason: ~tp " ,
144- [rabbit_federation_upstream :params_to_string (UParams ),
141+ ? LOG_WARNING ( " Federation ~ts did not connect to ~ts . Reason: ~tp " ,
142+ [rabbit_misc : rs ( XorQName ), rabbit_federation_upstream :params_to_string (UParams ),
145143 E ]),
146144 {stop , {shutdown , restart }, State };
147145
148146connection_error (remote , E , Upstream , UParams , XorQName , State ) ->
149147 rabbit_federation_status :report (
150148 Upstream , UParams , XorQName , clean_reason (E )),
151- log_info ( XorQName , " disconnected from ~ts~n~tp " ,
152- [rabbit_federation_upstream :params_to_string (UParams ), E ]),
149+ ? LOG_INFO ( " Federation ~ts disconnected from ~ts~n~tp " ,
150+ [rabbit_misc : rs ( XorQName ), rabbit_federation_upstream :params_to_string (UParams ), E ]),
153151 {stop , {shutdown , restart }, State };
154152
155153connection_error (command_channel , E , Upstream , UParams , XorQName , State ) ->
156154 rabbit_federation_status :report (
157155 Upstream , UParams , XorQName , clean_reason (E )),
158- log_info ( XorQName , " failed to open a command channel for upstream ~ts~n~tp " ,
159- [rabbit_federation_upstream :params_to_string (UParams ), E ]),
156+ ? LOG_INFO ( " Federation ~ts failed to open a command channel for upstream ~ts~n~tp " ,
157+ [rabbit_misc : rs ( XorQName ), rabbit_federation_upstream :params_to_string (UParams ), E ]),
160158 {stop , {shutdown , restart }, State };
161159
162160connection_error (local , basic_cancel , Upstream , UParams , XorQName , State ) ->
163161 rabbit_federation_status :report (
164162 Upstream , UParams , XorQName , {error , basic_cancel }),
165- log_info ( XorQName , " received a 'basic.cancel'" , []),
163+ ? LOG_INFO ( " Federation ~ts received a 'basic.cancel'" , [rabbit_misc : rs ( XorQName ) ]),
166164 {stop , {shutdown , restart }, State };
167165
168166connection_error (local_start , E , Upstream , UParams , XorQName , State ) ->
169167 rabbit_federation_status :report (
170168 Upstream , UParams , XorQName , clean_reason (E )),
171- log_warning ( XorQName , " did not connect locally~n~tp " , [E ]),
169+ ? LOG_WARNING ( " Federation ~ts did not connect locally~n~tp " , [rabbit_misc : rs ( XorQName ), E ]),
172170 {stop , {shutdown , restart }, State }.
173171
174172% % If we terminate due to a gen_server call exploding (almost
@@ -285,7 +283,7 @@ log_terminate(shutdown, Upstream, UParams, XorQName) ->
285283 % % the link because configuration has changed. So try to shut down
286284 % % nicely so that we do not cause unacked messages to be
287285 % % redelivered.
288- log_info ( XorQName , " disconnecting from ~ts " ,
286+ ? LOG_INFO ( " disconnecting from ~ts " ,
289287 [rabbit_federation_upstream :params_to_string (UParams )]),
290288 rabbit_federation_status :remove (Upstream , XorQName );
291289
@@ -295,21 +293,6 @@ log_terminate(Reason, Upstream, UParams, XorQName) ->
295293 rabbit_federation_status :report (
296294 Upstream , UParams , XorQName , clean_reason (Reason )).
297295
298- log_debug (XorQName , Fmt , Args ) -> log (debug , XorQName , Fmt , Args ).
299- log_info (XorQName , Fmt , Args ) -> log (info , XorQName , Fmt , Args ).
300- log_warning (XorQName , Fmt , Args ) -> log (warning , XorQName , Fmt , Args ).
301- log_error (XorQName , Fmt , Args ) -> log (error , XorQName , Fmt , Args ).
302-
303- log (Level , XorQName , Fmt0 , Args0 ) ->
304- Fmt = " Federation ~ts " ++ Fmt0 ,
305- Args = [rabbit_misc :rs (XorQName ) | Args0 ],
306- case Level of
307- debug -> rabbit_log_federation :debug (Fmt , Args );
308- info -> rabbit_log_federation :info (Fmt , Args );
309- warning -> rabbit_log_federation :warning (Fmt , Args );
310- error -> rabbit_log_federation :error (Fmt , Args )
311- end .
312-
313296% %----------------------------------------------------------------------------
314297
315298disposable_channel_call (Conn , Method ) ->
@@ -327,12 +310,13 @@ disposable_channel_call(Conn, Method, ErrFun) ->
327310 end
328311 catch
329312 Exception :Reason ->
330- rabbit_log_federation :error (" Federation link could not create a disposable (one-off) channel due to an error ~tp : ~tp " , [Exception , Reason ])
313+ ? LOG_ERROR (" Federation link could not create a disposable (one-off) channel due to an error ~tp : ~tp " ,
314+ [Exception , Reason ])
331315 end .
332316
333317disposable_connection_call (Params , Method , ErrFun ) ->
334318 try
335- rabbit_log_federation : debug (" Disposable connection parameters: ~tp " , [Params ]),
319+ ? LOG_DEBUG (" Disposable connection parameters: ~tp " , [Params ]),
336320 case open (Params , <<" Disposable exchange federation link connection" >>) of
337321 {ok , Conn , Ch } ->
338322 try
@@ -345,15 +329,15 @@ disposable_connection_call(Params, Method, ErrFun) ->
345329 ensure_connection_closed (Conn )
346330 end ;
347331 {error , {auth_failure , Message }} ->
348- rabbit_log_federation : error (" Federation link could not open a disposable (one-off) connection "
349- " due to an authentication failure: ~ts " , [Message ]);
332+ ? LOG_ERROR (" Federation link could not open a disposable (one-off) connection "
333+ " due to an authentication failure: ~ts " , [Message ]);
350334 Error ->
351- rabbit_log_federation : error (" Federation link could not open a disposable (one-off) connection, "
352- " reason: ~tp " , [Error ]),
335+ ? LOG_ERROR (" Federation link could not open a disposable (one-off) connection, "
336+ " reason: ~tp " , [Error ]),
353337 Error
354338 end
355339 catch
356340 Exception :Reason ->
357- rabbit_log_federation : error (" Federation link could not create a disposable (one-off) connection "
358- " due to an error ~tp : ~tp " , [Exception , Reason ])
341+ ? LOG_ERROR (" Federation link could not create a disposable (one-off) connection "
342+ " due to an error ~tp : ~tp " , [Exception , Reason ])
359343 end .
0 commit comments