Detect early if logger will be used
This spares unnecessary
StringBuilder creation when the logger
will not be used to log the message.
@@ -676,6 +676,9 @@ public Mouse getMouse() {
* @param when verb tense of "Execute" to prefix message
*/
protected void log(SessionId sessionId, String commandName, Object toLog, When when) {
+ if (!logger.isLoggable(level)) {
+ return;
+ }
String text = "" + toLog;
if (commandName.equals(DriverCommand.EXECUTE_SCRIPT)
|| commandName.equals(DriverCommand.EXECUTE_ASYNC_SCRIPT)) {
