zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] BELUGABEHR commented on a change in pull request #878: ZOOKEEPER-3339: Improve Debug and Trace Log Statements
Date Fri, 26 Apr 2019 14:39:05 GMT
BELUGABEHR commented on a change in pull request #878: ZOOKEEPER-3339: Improve Debug and Trace
Log Statements
URL: https://github.com/apache/zookeeper/pull/878#discussion_r278977754
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java
 ##########
 @@ -812,11 +812,13 @@ public void finishSessionInit(ServerCnxn cnxn, boolean valid) {
             cnxn.sendBuffer(bb);
 
             if (valid) {
-                LOG.debug("Established session 0x"
-                        + Long.toHexString(cnxn.getSessionId())
-                        + " with negotiated timeout " + cnxn.getSessionTimeout()
-                        + " for client "
-                        + cnxn.getRemoteSocketAddress());
+                if (LOG.isDebugEnabled()) {
 
 Review comment:
   The idea with parameter logging in SLF4J is that it avoids doing any real work unless the
specified log-level is met.  In this example, parameters could of course be used, but the
code would still call `Long.toHexString(sessionId)` for every iteration and the results of
that work would be thrown away (unless debug logging is enabled).  It also has to deal with
that conditional.  It's better just to skip this code altogether if debug logs are disabled.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message