You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The reason we use the logger.isDebugEnabled() if statement is so that we avoid calling logger.debug if Debug is not enabled. Best practice is to evaluate this inline. Also best practice is only to include this isDebugEnabled check is when the string contains something that requires evaluation or has a method call, such as object.toXml() or map.toString(). It's best practice not to use the isDebugEnabled test when the string is just a concatenation of strings and string variables. Hence burying the isDebugEnabled method in another method, for something like logDebug("This is a string"), is overkill (not needed), and for something like logDebug("This is a map: "+map.toString()) it defeats the purpose because the system has to execute the toString() method even if the debug level is not enabled.
For instance:
logDebug("Processing attribute request: " + attributeRequest.toXml());
this statement expands the toXml() method even if debug level is not enabled.
Expected behavior
Remove the logDebug() method call and replace with if(logger.isDebugEnabled())logger.debug(""); only when the string has a method call or object reference, and replace with simple logger.debug("string"+variable+etc); for simple strings.
The text was updated successfully, but these errors were encountered:
Describe the bug
The reason we use the logger.isDebugEnabled() if statement is so that we avoid calling logger.debug if Debug is not enabled. Best practice is to evaluate this inline. Also best practice is only to include this isDebugEnabled check is when the string contains something that requires evaluation or has a method call, such as object.toXml() or map.toString(). It's best practice not to use the isDebugEnabled test when the string is just a concatenation of strings and string variables. Hence burying the isDebugEnabled method in another method, for something like logDebug("This is a string"), is overkill (not needed), and for something like logDebug("This is a map: "+map.toString()) it defeats the purpose because the system has to execute the toString() method even if the debug level is not enabled.
For instance:
logDebug("Processing attribute request: " + attributeRequest.toXml());
this statement expands the toXml() method even if debug level is not enabled.
Expected behavior
Remove the logDebug() method call and replace with if(logger.isDebugEnabled())logger.debug(""); only when the string has a method call or object reference, and replace with simple logger.debug("string"+variable+etc); for simple strings.
The text was updated successfully, but these errors were encountered: