chore: remove the duplicated clientid print in log

This commit is contained in:
JianBo He 2022-09-28 18:15:19 +08:00
parent 4cf3d181d8
commit 317ef65c7e
2 changed files with 8 additions and 10 deletions

View File

@ -41,19 +41,18 @@ check_acl(#{username := <<$$, _/binary>>}, _PubSub, _Topic, _AclResult, _Params)
ok; ok;
check_acl(ClientInfo, PubSub, Topic, _AclResult, #{acl := ACLParams = #{path := Path}}) -> check_acl(ClientInfo, PubSub, Topic, _AclResult, #{acl := ACLParams = #{path := Path}}) ->
ClientInfo1 = ClientInfo#{access => access(PubSub), topic => Topic}, ClientInfo1 = ClientInfo#{access => access(PubSub), topic => Topic},
ClientId = maps:get(clientid, ClientInfo1, undefined),
Username = maps:get(username, ClientInfo1, undefined), Username = maps:get(username, ClientInfo1, undefined),
case check_acl_request(ACLParams, ClientInfo1) of case check_acl_request(ACLParams, ClientInfo1) of
{ok, 200, <<"ignore">>} -> ok; {ok, 200, <<"ignore">>} -> ok;
{ok, 200, _Body} -> {stop, allow}; {ok, 200, _Body} -> {stop, allow};
{ok, Code, _Body} -> {ok, Code, _Body} ->
?LOG(error, "Deny ~s ~s to topic ~s, username: ~p, http response code: ~p", ?LOG(error, "Deny ~s to topic ~s, username: ~p, http response code: ~p",
[ClientId, PubSub, Topic, Username, Code]), [PubSub, Topic, Username, Code]),
{stop, deny}; {stop, deny};
{error, Error} -> {error, Error} ->
?LOG(error, "Deny ~s ~s to topic ~s, username: ~p, due to request " ?LOG(error, "Deny ~s to topic ~s, username: ~p, due to request "
"http server failure, path: ~p, error: ~0p", "http server failure, path: ~p, error: ~0p",
[ClientId, PubSub, Topic, Username, Path, Error]), [PubSub, Topic, Username, Path, Error]),
ok ok
end. end.

View File

@ -36,7 +36,6 @@
check(ClientInfo, AuthResult, #{auth := AuthParms = #{path := Path}, check(ClientInfo, AuthResult, #{auth := AuthParms = #{path := Path},
super := SuperParams}) -> super := SuperParams}) ->
ClientId = maps:get(clientid, ClientInfo, undefined),
Username = maps:get(username, ClientInfo, undefined), Username = maps:get(username, ClientInfo, undefined),
case authenticate(AuthParms, ClientInfo) of case authenticate(AuthParms, ClientInfo) of
{ok, 200, <<"ignore">>} -> {ok, 200, <<"ignore">>} ->
@ -48,15 +47,15 @@ check(ClientInfo, AuthResult, #{auth := AuthParms = #{path := Path},
anonymous => false, anonymous => false,
mountpoint => mountpoint(Body, ClientInfo)}}; mountpoint => mountpoint(Body, ClientInfo)}};
{ok, Code, _Body} -> {ok, Code, _Body} ->
?LOG(error, "Deny connection(~s) from path: ~s, username: ~s, http " ?LOG(error, "Deny connection from path: ~s, username: ~s, http "
"response code: ~p", "response code: ~p",
[ClientId, Path, Username, Code]), [Path, Username, Code]),
{stop, AuthResult#{auth_result => http_to_connack_error(Code), {stop, AuthResult#{auth_result => http_to_connack_error(Code),
anonymous => false}}; anonymous => false}};
{error, Error} -> {error, Error} ->
?LOG(error, "Deny connection(~s) from path: ~s, username: ~s, due to " ?LOG(error, "Deny connection from path: ~s, username: ~s, due to "
"request http-server failed: ~0p", "request http-server failed: ~0p",
[ClientId, Path, Username, Error]), [Path, Username, Error]),
%%FIXME later: server_unavailable is not right. %%FIXME later: server_unavailable is not right.
{stop, AuthResult#{auth_result => server_unavailable, {stop, AuthResult#{auth_result => server_unavailable,
anonymous => false}} anonymous => false}}