You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by jg...@apache.org on 2022/05/22 01:14:11 UTC

[kafka] branch trunk updated: MINOR: Use parameterized logging in StandardAuthorizer and StandardAuthorizerData (#12192)

This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 4878653016 MINOR: Use parameterized logging in StandardAuthorizer and StandardAuthorizerData (#12192)
4878653016 is described below

commit 4878653016c32e55d6e829ea1b4f80a825459706
Author: andymg3 <97...@users.noreply.github.com>
AuthorDate: Sat May 21 21:14:02 2022 -0400

    MINOR: Use parameterized logging in StandardAuthorizer and StandardAuthorizerData (#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 <ja...@confluent.io>
---
 .../apache/kafka/metadata/authorizer/StandardAuthorizer.java   |  3 +--
 .../kafka/metadata/authorizer/StandardAuthorizerData.java      | 10 +++-------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizer.java b/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizer.java
index 611625a4f3..42f03367c2 100644
--- a/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizer.java
+++ b/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizer.java
@@ -166,8 +166,7 @@ public class StandardAuthorizer implements ClusterMetadataAuthorizer {
             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
diff --git a/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizerData.java b/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizerData.java
index b46c839e4f..d9ffd17562 100644
--- a/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizerData.java
+++ b/metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizerData.java
@@ -198,7 +198,7 @@ public class StandardAuthorizerData {
         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;
     }
 
@@ -213,9 +213,7 @@ public class StandardAuthorizerData {
                 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;
@@ -232,9 +230,7 @@ public class StandardAuthorizerData {
                 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;