Skip to content

Commit

Permalink
MINOR: Use parameterized logging in StandardAuthorizer and StandardAu…
Browse files Browse the repository at this point in the history
…thorizerData (apache#12192)

This updates StandardAuthorizer and StandardAuthorizerData to use parameterized logging per the SLF4J recommendation (see https://www.slf4j.org/faq.html). This also removes a couple if statements that explicitly check if trace is enabled, but the logger should handle not publishing the message and not constructing the String if trace is not enabled.

Reviewers: Jason Gustafson <[email protected]>
  • Loading branch information
andymg3 authored May 22, 2022
1 parent f6ba10e commit 4878653
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ public synchronized void configure(Map<String, ?> configs) {
nodeId = -1;
}
this.data = data.copyWithNewConfig(nodeId, superUsers, defaultResult);
this.data.log.info("set super.users=" + String.join(",", superUsers) +
", default result=" + defaultResult);
this.data.log.info("set super.users={}, default result={}", String.join(",", superUsers), defaultResult);
}

// VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ StandardAuthorizerData copyWithNewAcls(Collection<Entry<Uuid, StandardAcl>> aclE
for (Entry<Uuid, StandardAcl> entry : aclEntries) {
newData.addAcl(entry.getKey(), entry.getValue());
}
log.info("Applied " + aclEntries.size() + "acl(s) from image.");
log.info("Applied {} acl(s) from image.", aclEntries.size());
return newData;
}

Expand All @@ -213,9 +213,7 @@ void addAcl(Uuid id, StandardAcl acl) {
throw new RuntimeException("Unable to add the ACL with ID " + id +
" to aclsByResource");
}
if (log.isTraceEnabled()) {
log.trace("Added ACL " + id + ": " + acl);
}
log.trace("Added ACL {}: {}", id, acl);
} catch (Throwable e) {
log.error("addAcl error", e);
throw e;
Expand All @@ -232,9 +230,7 @@ void removeAcl(Uuid id) {
throw new RuntimeException("Unable to remove the ACL with ID " + id +
" from aclsByResource");
}
if (log.isTraceEnabled()) {
log.trace("Removed ACL " + id + ": " + acl);
}
log.trace("Removed ACL {}: {}", id, acl);
} catch (Throwable e) {
log.error("removeAcl error", e);
throw e;
Expand Down

0 comments on commit 4878653

Please sign in to comment.