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_r278977710
##########
File path:
zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxn.java
##########
@@ -610,11 +604,14 @@ private void closeSock() {
return;
}
- LOG.debug("Closed socket connection for client "
- + sock.socket().getRemoteSocketAddress()
- + (sessionId != 0 ?
- " which had sessionid 0x" +
Long.toHexString(sessionId) :
- " (no session established for client)"));
+ 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:
[email protected]
With regards,
Apache Git Services