Skip to content

Commit 4a9a745

Browse files
committed
[skip ci] Remove rabbit_log_ldad and use LOG_ macros
1 parent 231bf48 commit 4a9a745

File tree

3 files changed

+23
-126
lines changed

3 files changed

+23
-126
lines changed

deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap.erl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
-include_lib("eldap/include/eldap.hrl").
1313
-include_lib("rabbit_common/include/rabbit.hrl").
14+
-include_lib("kernel/include/logger.hrl").
15+
-include("logging.hrl").
1416

1517
-behaviour(rabbit_authn_backend).
1618
-behaviour(rabbit_authz_backend).
@@ -514,18 +516,16 @@ with_ldap({ok, Creds}, Fun, Servers) ->
514516
Opts1 = case env(log) of
515517
network ->
516518
Pre = " LDAP network traffic: ",
517-
rabbit_log_ldap:info(
518-
" LDAP connecting to servers: ~tp", [Servers]),
519-
[{log, fun(1, S, A) -> rabbit_log_ldap:warning(Pre ++ S, A);
519+
?LOG_INFO("LDAP connecting to servers: ~tp", [Servers]),
520+
[{log, fun(1, S, A) -> ?LOG_WARNING(Pre ++ S, A);
520521
(2, S, A) ->
521-
rabbit_log_ldap:info(Pre ++ S, scrub_creds(A, []))
522+
?LOG_INFO(Pre ++ S, scrub_creds(A, []))
522523
end} | Opts0];
523524
network_unsafe ->
524525
Pre = " LDAP network traffic: ",
525-
rabbit_log_ldap:info(
526-
" LDAP connecting to servers: ~tp", [Servers]),
527-
[{log, fun(1, S, A) -> rabbit_log_ldap:warning(Pre ++ S, A);
528-
(2, S, A) -> rabbit_log_ldap:info( Pre ++ S, A)
526+
?LOG_INFO(" LDAP connecting to servers: ~tp", [Servers]),
527+
[{log, fun(1, S, A) -> ?LOG_WARNING(Pre ++ S, A);
528+
(2, S, A) -> ?LOG_INFO( Pre ++ S, A)
529529
end} | Opts0];
530530
_ ->
531531
Opts0
@@ -550,7 +550,7 @@ with_ldap({ok, Creds}, Fun, Servers) ->
550550
with_login(Creds, Servers, Opts, Fun) ->
551551
with_login(Creds, Servers, Opts, Fun, ?LDAP_OPERATION_RETRIES).
552552
with_login(_Creds, _Servers, _Opts, _Fun, 0 = _RetriesLeft) ->
553-
rabbit_log_ldap:warning("LDAP failed to perform an operation. TCP connection to a LDAP server was closed or otherwise defunct. Exhausted all retries."),
553+
?LOG_WARNING("LDAP failed to perform an operation. TCP connection to a LDAP server was closed or otherwise defunct. Exhausted all retries."),
554554
{error, ldap_connect_error};
555555
with_login(Creds, Servers, Opts, Fun, RetriesLeft) ->
556556
case get_or_create_conn(Creds == anon, Servers, Opts) of
@@ -609,9 +609,9 @@ with_login(Creds, Servers, Opts, Fun, RetriesLeft) ->
609609

610610
purge_connection(Creds, Servers, Opts) ->
611611
%% purge and retry with a new connection
612-
rabbit_log_ldap:warning("TCP connection to a LDAP server was closed or otherwise defunct."),
612+
?LOG_WARNING("TCP connection to a LDAP server was closed or otherwise defunct."),
613613
purge_conn(Creds == anon, Servers, Opts),
614-
rabbit_log_ldap:warning("LDAP will retry with a new connection.").
614+
?LOG_WARNING("LDAP will retry with a new connection.").
615615

616616
call_ldap_fun(Fun, LDAP) ->
617617
call_ldap_fun(Fun, LDAP, "").
@@ -725,7 +725,7 @@ purge_conn(IsAnon, Servers, Opts) ->
725725
Conns = get(ldap_conns),
726726
Key = {IsAnon, Servers, Opts},
727727
{ok, Conn} = maps:find(Key, Conns),
728-
rabbit_log_ldap:warning("LDAP will purge an already closed or defunct LDAP server connection from the pool"),
728+
?LOG_WARNING("LDAP will purge an already closed or defunct LDAP server connection from the pool"),
729729
% We cannot close the connection with eldap:close/1 because as of OTP-13327
730730
% eldap will try to do_unbind first and will fail with a `{gen_tcp_error, closed}`.
731731
% Since we know that the connection is already closed, we just
@@ -770,7 +770,7 @@ ssl_options() ->
770770
Opts0 = rabbit_ssl_options:fix_client(env(ssl_options)),
771771
case env(ssl_hostname_verification, undefined) of
772772
wildcard ->
773-
rabbit_log_ldap:debug("Enabling wildcard-aware hostname verification for LDAP client connections"),
773+
?LOG_DEBUG("Enabling wildcard-aware hostname verification for LDAP client connections"),
774774
%% Needed for non-HTTPS connections that connect to servers that use wildcard certificates.
775775
%% See https://erlang.org/doc/man/public_key.html#pkix_verify_hostname_match_fun-1.
776776
[{customize_hostname_check, [{match_fun, public_key:pkix_verify_hostname_match_fun(https)}]} | Opts0];
@@ -786,7 +786,7 @@ at_least(Ver) ->
786786
get_expected_env_str(Key, Default) ->
787787
V = case env(Key) of
788788
Default ->
789-
rabbit_log_ldap:warning("rabbitmq_auth_backend_ldap configuration key '~tp' is set to "
789+
?LOG_WARNING("rabbitmq_auth_backend_ldap configuration key '~tp' is set to "
790790
"the default value of '~tp', expected to get a non-default value",
791791
[Key, Default]),
792792
Default;
@@ -884,7 +884,7 @@ dn_lookup(Username, LDAP) ->
884884
?L1("DN lookup: ~ts -> ~ts", [Username, DN]),
885885
DN;
886886
{ok, {eldap_search_result, Entries, _Referrals, _Controls}} ->
887-
rabbit_log_ldap:warning("Searching for DN for ~ts, got back ~tp",
887+
?LOG_WARNING("Searching for DN for ~ts, got back ~tp",
888888
[Filled, Entries]),
889889
Filled;
890890
{error, _} = E ->
@@ -963,7 +963,7 @@ is_dn(_S) -> false.
963963

964964
log(Fmt, Args) -> case env(log) of
965965
false -> ok;
966-
_ -> rabbit_log_ldap:info(Fmt ++ "", Args)
966+
_ -> ?LOG_INFO(Fmt ++ "", Args)
967967
end.
968968

969969
fill(Fmt, Args) ->

deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap_app.erl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
-behaviour(application).
1111
-export([start/2, stop/1]).
1212

13+
-include_lib("kernel/include/logger.hrl").
14+
-include("logging.hrl").
15+
1316
%% Dummy supervisor - see Ulf Wiger's comment at
1417
%% http://erlang.org/pipermail/erlang-questions/2010-April/050508.html
1518
-behaviour(supervisor).
@@ -28,7 +31,7 @@ start(_Type, _StartArgs) ->
2831
{ok, Backends} = application:get_env(rabbit, auth_backends),
2932
case configured(rabbit_auth_backend_ldap, Backends) of
3033
true -> ok;
31-
false -> rabbit_log_ldap:warning(
34+
false -> ?LOG_WARNING(
3235
"LDAP plugin loaded, but rabbit_auth_backend_ldap is not "
3336
"in the list of auth_backends. LDAP auth will not work.")
3437
end,
@@ -53,4 +56,6 @@ configured(M, [_ |T]) -> configured(M, T).
5356

5457
%%----------------------------------------------------------------------------
5558

56-
init([]) -> {ok, {{one_for_one, 3, 10}, []}}.
59+
init([]) ->
60+
logger:set_process_metadata(#{domain => ?RMQLOG_DOMAIN_LDAP}),
61+
{ok, {{one_for_one, 3, 10}, []}}.

deps/rabbitmq_auth_backend_ldap/src/rabbit_log_ldap.erl

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

0 commit comments

Comments
 (0)