diff --git a/java/src/org/openqa/selenium/bidi/Connection.java b/java/src/org/openqa/selenium/bidi/Connection.java index 6d51381fc67ea..ce34ae3fccc43 100644 --- a/java/src/org/openqa/selenium/bidi/Connection.java +++ b/java/src/org/openqa/selenium/bidi/Connection.java @@ -18,7 +18,6 @@ package org.openqa.selenium.bidi; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.openqa.selenium.internal.Debug.getDebugLogLevel; import static org.openqa.selenium.json.Json.MAP_TYPE; import static org.openqa.selenium.remote.http.HttpMethod.GET; @@ -148,7 +147,7 @@ public String toString() { try (JsonOutput out = JSON.newOutput(json).writeClassName(false)) { out.write(serialized); } - LOG.log(getDebugLogLevel(), "-> {0}", json); + LOG.log(Level.FINE, "-> {0}", json); socket.sendText(json); if (!command.getSendsResponse()) { @@ -353,7 +352,7 @@ private void handle(CharSequence data) { // value to the command's mapper and an event passes its "params" Map to the event's mapper; // neither re-parses the message text. String asString = String.valueOf(data); - LOG.log(getDebugLogLevel(), "<- {0}", asString); + LOG.log(Level.FINE, "<- {0}", asString); Map raw = JSON.toType(asString, MAP_TYPE); if (raw.get("id") instanceof Number @@ -382,7 +381,7 @@ private void handleResponse(Map rawDataMap) { private void handleEventResponse(Map rawDataMap) { LOG.log( - getDebugLogLevel(), + Level.FINE, () -> String.format( "Method %s called with %s callbacks available", @@ -413,7 +412,7 @@ private void dispatchEvent(Map rawDataMap) { eventCallbacks.entrySet().stream() .filter(event -> { LOG.log( - getDebugLogLevel(), + Level.FINE, "Matching {0} with {1}", new Object[] {rawDataMap.get("method"), event.getKey().getMethod()}); return rawDataMap.get("method").equals(event.getKey().getMethod()); @@ -434,7 +433,7 @@ private void dispatchEvent(Map rawDataMap) { @SuppressWarnings("unchecked") Consumer obj = (Consumer) action; LOG.log( - getDebugLogLevel(), + Level.FINE, "Calling callback for {0} using {1} being passed {2}", new Object[] {event.getKey(), obj, finalValue}); obj.accept(finalValue); diff --git a/java/src/org/openqa/selenium/devtools/Connection.java b/java/src/org/openqa/selenium/devtools/Connection.java index 6249a510526e4..d97a662821563 100644 --- a/java/src/org/openqa/selenium/devtools/Connection.java +++ b/java/src/org/openqa/selenium/devtools/Connection.java @@ -18,7 +18,6 @@ package org.openqa.selenium.devtools; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.openqa.selenium.internal.Debug.getDebugLogLevel; import static org.openqa.selenium.json.Json.MAP_TYPE; import static org.openqa.selenium.remote.http.HttpMethod.GET; @@ -181,7 +180,7 @@ public CompletableFuture send(@Nullable SessionID sessionId, Command c try (JsonOutput out = JSON.newOutput(json).writeClassName(false)) { out.write(Map.copyOf(serialized)); } - LOG.log(getDebugLogLevel(), "-> {0}", json); + LOG.log(Level.FINE, "-> {0}", json); socket.sendText(json); if (!command.getSendsResponse()) { @@ -265,7 +264,7 @@ private void handle(long sequence, CharSequence data) { // TODO: decode once, and once only String asString = String.valueOf(data); - LOG.log(getDebugLogLevel(), "<- {0}", asString); + LOG.log(Level.FINE, "<- {0}", asString); Map raw = JSON.toType(asString, MAP_TYPE); if (raw.get("id") instanceof Number @@ -298,7 +297,7 @@ private void handle(long sequence, CharSequence data) { } } else if (raw.get("method") instanceof String && raw.get("params") instanceof Map) { LOG.log( - getDebugLogLevel(), + Level.FINE, "Method {0} called with {1} callbacks available", new Object[] {raw.get("method"), eventCallbacks.size()}); Lock lock = callbacksLock.readLock(); @@ -317,7 +316,7 @@ private void handle(long sequence, CharSequence data) { eventCallbacks.entrySet().stream() .peek(event -> LOG.log( - getDebugLogLevel(), + Level.FINE, "Matching {0} with {1}", new Object[] {raw.get("method"), event.getKey().getMethod()})) .filter(event -> raw.get("method").equals(event.getKey().getMethod())) @@ -352,7 +351,7 @@ private void handle(long sequence, CharSequence data) { @SuppressWarnings("unchecked") BiConsumer obj = (BiConsumer) action; LOG.log( - getDebugLogLevel(), + Level.FINE, "Calling callback for {0} using {1} being passed {2}", new Object[] {event.getKey(), obj, params}); obj.accept(sequence, params); diff --git a/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java b/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java index 8657a040b1887..cda98b74f4cf5 100644 --- a/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java +++ b/java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java @@ -18,7 +18,6 @@ package org.openqa.selenium.grid.distributor.local; import static org.openqa.selenium.concurrent.ExecutorServices.shutdownGracefully; -import static org.openqa.selenium.internal.Debug.getDebugLogLevel; import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES; import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES_EVENT; import static org.openqa.selenium.remote.RemoteTags.SESSION_ID; @@ -457,7 +456,7 @@ private SlotId reserveSlot(RequestId requestId, Capabilities caps) { Set slotIds = slotSelector.selectSlot(caps, getAvailableNodes(), slotMatcher); if (slotIds.isEmpty()) { LOG.log( - getDebugLogLevel(), + Level.FINE, String.format("No slots found for request %s and capabilities %s", requestId, caps)); return null; } @@ -566,9 +565,7 @@ public void run() { sessionCreatorExecutor.execute(() -> handleNewSessionRequest(req)); } catch (RejectedExecutionException e) { LOG.log( - getDebugLogLevel(), - "Dropping session creation task while shutting down distributor", - e); + Level.FINE, "Dropping session creation task while shutting down distributor", e); } }); } @@ -619,8 +616,8 @@ private void handleNewSessionRequest(SessionRequest sessionRequest) { if (response.isLeft() && response.left() instanceof RetrySessionRequestException) { try (Span childSpan = span.createSpan("distributor.retry")) { - if (LOG.isLoggable(getDebugLogLevel())) { - LOG.log(getDebugLogLevel(), "Retrying {0}", sessionRequest.getDesiredCapabilities()); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "Retrying {0}", sessionRequest.getDesiredCapabilities()); } boolean retried = sessionQueue.retryAddToQueue(sessionRequest); diff --git a/java/src/org/openqa/selenium/grid/distributor/local/LocalGridModel.java b/java/src/org/openqa/selenium/grid/distributor/local/LocalGridModel.java index 3f5fe1d13637f..742196a47fc43 100644 --- a/java/src/org/openqa/selenium/grid/distributor/local/LocalGridModel.java +++ b/java/src/org/openqa/selenium/grid/distributor/local/LocalGridModel.java @@ -33,6 +33,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.logging.Level; import java.util.logging.Logger; import org.jspecify.annotations.Nullable; import org.openqa.selenium.events.EventBus; @@ -49,7 +50,6 @@ import org.openqa.selenium.grid.data.SlotId; import org.openqa.selenium.grid.distributor.GridModel; import org.openqa.selenium.grid.server.EventBusOptions; -import org.openqa.selenium.internal.Debug; import org.openqa.selenium.internal.Require; import org.openqa.selenium.remote.SessionId; @@ -101,7 +101,7 @@ public void add(NodeStatus node) { && next.getExternalUri().equals(node.getExternalUri())) { iterator.remove(); - LOG.log(Debug.getDebugLogLevel(), "Refreshing node with id {0}", node.getNodeId()); + LOG.log(Level.FINE, "Refreshing node with id {0}", node.getNodeId()); NodeStatus refreshed = rewrite(node, next.getAvailability()); nodes.add(refreshed); nodePurgeTimes.put(refreshed.getNodeId(), Instant.now()); @@ -140,7 +140,7 @@ public void add(NodeStatus node) { // Nodes are initially added in the "down" state until something changes their availability LOG.log( - Debug.getDebugLogLevel(), + Level.FINE, "Adding node with id {0} and URI {1}", new Object[] {node.getNodeId(), node.getExternalUri()}); NodeStatus refreshed = rewrite(node, DOWN); diff --git a/java/src/org/openqa/selenium/grid/distributor/local/LocalNodeRegistry.java b/java/src/org/openqa/selenium/grid/distributor/local/LocalNodeRegistry.java index 3827f5b5f0895..e3e2959cb978e 100644 --- a/java/src/org/openqa/selenium/grid/distributor/local/LocalNodeRegistry.java +++ b/java/src/org/openqa/selenium/grid/distributor/local/LocalNodeRegistry.java @@ -22,7 +22,6 @@ import static org.openqa.selenium.grid.data.Availability.DOWN; import static org.openqa.selenium.grid.data.Availability.DRAINING; import static org.openqa.selenium.grid.data.Availability.UP; -import static org.openqa.selenium.internal.Debug.getDebugLogLevel; import java.net.URI; import java.time.Duration; @@ -225,8 +224,7 @@ public void add(Node node) { writeLock.unlock(); } } catch (Exception e) { - LOG.log( - getDebugLogLevel(), String.format("Exception while adding Node %s", node.getUri()), e); + LOG.log(Level.FINE, String.format("Exception while adding Node %s", node.getUri()), e); return; } @@ -296,8 +294,7 @@ public void updateNodeAvailability(URI nodeUri, NodeId id, Availability availabi writeLock.lock(); try { LOG.log( - getDebugLogLevel(), - String.format("Health check result for %s was %s", nodeUri, availability)); + Level.FINE, String.format("Health check result for %s was %s", nodeUri, availability)); model.setAvailability(id, availability); model.updateHealthCheckCount(id, availability); } finally { @@ -308,7 +305,7 @@ public void updateNodeAvailability(URI nodeUri, NodeId id, Availability availabi @Override public void runHealthChecks() { if (!healthChecksInProgress.compareAndSet(false, true)) { - LOG.log(getDebugLogLevel(), "Skipping health checks because previous cycle is still running"); + LOG.log(Level.FINE, "Skipping health checks because previous cycle is still running"); return; } @@ -332,7 +329,7 @@ public void runHealthChecks() { futures.add(nodeHealthCheckExecutor.submit(() -> runHealthCheck(nodeId, check))); } catch (RejectedExecutionException e) { LOG.log( - getDebugLogLevel(), + Level.FINE, String.format( "Unable to schedule health check for node %s, running in caller thread", nodeId), e); @@ -347,7 +344,7 @@ public void runHealthChecks() { Thread.currentThread().interrupt(); break; } catch (Exception e) { - LOG.log(getDebugLogLevel(), "Error waiting for health check execution", e); + LOG.log(Level.FINE, "Error waiting for health check execution", e); } } } finally { @@ -448,7 +445,7 @@ private void runHealthCheck(NodeId nodeId, Runnable check) { try { check.run(); } catch (Throwable t) { - LOG.log(getDebugLogLevel(), "Health check execution failed for node " + nodeId, t); + LOG.log(Level.FINE, "Health check execution failed for node " + nodeId, t); } } @@ -458,7 +455,7 @@ private Runnable asRunnableHealthCheck(Node node) { return () -> { boolean checkFailed = false; Exception failedCheckException = null; - LOG.log(getDebugLogLevel(), "Running healthcheck for Node " + node.getUri()); + LOG.log(Level.FINE, "Running healthcheck for Node " + node.getUri()); HealthCheck.Result result; try { @@ -496,7 +493,7 @@ public boolean reserve(SlotId slotId) { NodeId nodeId = slotId.getOwningNodeId(); Node node = nodes.get(nodeId); if (node == null) { - LOG.log(getDebugLogLevel(), String.format("Unable to find node with id %s", slotId)); + LOG.log(Level.FINE, String.format("Unable to find node with id %s", slotId)); return false; } diff --git a/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedDistributor.java b/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedDistributor.java index 978e6528961f3..4cf2de2a25971 100644 --- a/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedDistributor.java +++ b/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedDistributor.java @@ -18,7 +18,6 @@ package org.openqa.selenium.grid.distributor.redis; import static org.openqa.selenium.concurrent.ExecutorServices.shutdownGracefully; -import static org.openqa.selenium.internal.Debug.getDebugLogLevel; import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES; import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES_EVENT; import static org.openqa.selenium.remote.RemoteTags.SESSION_ID; @@ -501,7 +500,7 @@ private SlotId reserveSlot(RequestId requestId, Capabilities caps) { if (slotIds.isEmpty()) { LOG.log( - getDebugLogLevel(), + Level.FINE, String.format("No slots found for request %s and capabilities %s", requestId, caps)); return null; } @@ -623,9 +622,7 @@ public void run() { sessionCreatorExecutor.execute(() -> handleNewSessionRequest(req)); } catch (RejectedExecutionException e) { LOG.log( - getDebugLogLevel(), - "Dropping session creation task while shutting down distributor", - e); + Level.FINE, "Dropping session creation task while shutting down distributor", e); } }); } @@ -673,8 +670,8 @@ private void handleNewSessionRequest(SessionRequest sessionRequest) { if (response.isLeft() && response.left() instanceof RetrySessionRequestException) { try (Span childSpan = span.createSpan("distributor.retry")) { - if (LOG.isLoggable(getDebugLogLevel())) { - LOG.log(getDebugLogLevel(), "Retrying {0}", sessionRequest.getDesiredCapabilities()); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "Retrying {0}", sessionRequest.getDesiredCapabilities()); } boolean retried = sessionQueue.retryAddToQueue(sessionRequest); attributeMap.put("request.retry_add", retried); diff --git a/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedGridModel.java b/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedGridModel.java index ff0c912ed45f2..ade85d4ed31e1 100644 --- a/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedGridModel.java +++ b/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedGridModel.java @@ -26,6 +26,7 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.logging.Level; import java.util.logging.Logger; import org.jspecify.annotations.Nullable; import org.openqa.selenium.events.EventBus; @@ -40,7 +41,6 @@ import org.openqa.selenium.grid.data.Slot; import org.openqa.selenium.grid.data.SlotId; import org.openqa.selenium.grid.distributor.GridModel; -import org.openqa.selenium.internal.Debug; import org.openqa.selenium.internal.Require; import org.openqa.selenium.json.Json; import org.openqa.selenium.redis.GridRedisClient; @@ -197,7 +197,7 @@ public void add(NodeStatus node) { if (existing.getNodeId().equals(node.getNodeId()) && existing.getExternalUri().equals(node.getExternalUri())) { // Same node refreshing — keep existing availability. - LOG.log(Debug.getDebugLogLevel(), "Refreshing node with id {0}", node.getNodeId()); + LOG.log(Level.FINE, "Refreshing node with id {0}", node.getNodeId()); NodeStatus refreshed = rewrite(node, existing.getAvailability()); writeNodeBlob(refreshed); redis.set(lastTouchKey(node.getNodeId()), String.valueOf(Instant.now().toEpochMilli())); @@ -229,7 +229,7 @@ public void add(NodeStatus node) { // Add as DOWN until health check promotes it. LOG.log( - Debug.getDebugLogLevel(), + Level.FINE, "Adding node with id {0} and URI {1}", new Object[] {node.getNodeId(), node.getExternalUri()}); NodeStatus asDown = rewrite(node, DOWN); diff --git a/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedNodeRegistry.java b/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedNodeRegistry.java index 0dbcd5ca8d43d..ef15213f51fd4 100644 --- a/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedNodeRegistry.java +++ b/java/src/org/openqa/selenium/grid/distributor/redis/RedisBackedNodeRegistry.java @@ -22,7 +22,6 @@ import static org.openqa.selenium.grid.data.Availability.DOWN; import static org.openqa.selenium.grid.data.Availability.DRAINING; import static org.openqa.selenium.grid.data.Availability.UP; -import static org.openqa.selenium.internal.Debug.getDebugLogLevel; import java.net.URI; import java.time.Duration; @@ -289,8 +288,7 @@ public void add(Node node) { writeLock.unlock(); } } catch (Exception e) { - LOG.log( - getDebugLogLevel(), String.format("Exception while adding Node %s", node.getUri()), e); + LOG.log(Level.FINE, String.format("Exception while adding Node %s", node.getUri()), e); return; } @@ -359,8 +357,7 @@ public void updateNodeAvailability(URI nodeUri, NodeId id, Availability availabi writeLock.lock(); try { LOG.log( - getDebugLogLevel(), - String.format("Health check result for %s was %s", nodeUri, availability)); + Level.FINE, String.format("Health check result for %s was %s", nodeUri, availability)); model.setAvailability(id, availability); model.updateHealthCheckCount(id, availability); } finally { @@ -371,7 +368,7 @@ public void updateNodeAvailability(URI nodeUri, NodeId id, Availability availabi @Override public void runHealthChecks() { if (!healthChecksInProgress.compareAndSet(false, true)) { - LOG.log(getDebugLogLevel(), "Skipping health checks because previous cycle is still running"); + LOG.log(Level.FINE, "Skipping health checks because previous cycle is still running"); return; } @@ -397,7 +394,7 @@ public void runHealthChecks() { redis.setIfAbsent("grid:healthcheck:lock:" + nodeId, instanceId, lockTtlMillis); if (!won) { LOG.log( - getDebugLogLevel(), + Level.FINE, "Another replica is handling health check for node {0}, skipping", nodeId); return; @@ -406,7 +403,7 @@ public void runHealthChecks() { futures.add(nodeHealthCheckExecutor.submit(() -> runHealthCheck(nodeId, check))); } catch (RejectedExecutionException e) { LOG.log( - getDebugLogLevel(), + Level.FINE, String.format( "Unable to schedule health check for node %s, running in caller thread", nodeId), e); @@ -421,7 +418,7 @@ public void runHealthChecks() { Thread.currentThread().interrupt(); break; } catch (Exception e) { - LOG.log(getDebugLogLevel(), "Error waiting for health check execution", e); + LOG.log(Level.FINE, "Error waiting for health check execution", e); } } } finally { @@ -517,7 +514,7 @@ private void runHealthCheck(NodeId nodeId, Runnable check) { try { check.run(); } catch (Throwable t) { - LOG.log(getDebugLogLevel(), "Health check execution failed for node " + nodeId, t); + LOG.log(Level.FINE, "Health check execution failed for node " + nodeId, t); } } @@ -527,7 +524,7 @@ private Runnable asRunnableHealthCheck(Node node) { return () -> { boolean checkFailed = false; Exception failedCheckException = null; - LOG.log(getDebugLogLevel(), "Running healthcheck for Node " + node.getUri()); + LOG.log(Level.FINE, "Running healthcheck for Node " + node.getUri()); HealthCheck.Result result; try { @@ -556,7 +553,7 @@ public boolean reserve(SlotId slotId) { NodeId nodeId = slotId.getOwningNodeId(); Node node = nodes.get(nodeId); if (node == null) { - LOG.log(getDebugLogLevel(), String.format("Unable to find node with id %s", slotId)); + LOG.log(Level.FINE, String.format("Unable to find node with id %s", slotId)); return false; } try { diff --git a/java/src/org/openqa/selenium/grid/node/ProxyNodeWebsockets.java b/java/src/org/openqa/selenium/grid/node/ProxyNodeWebsockets.java index 54023c5899f9c..d250785aa5eab 100644 --- a/java/src/org/openqa/selenium/grid/node/ProxyNodeWebsockets.java +++ b/java/src/org/openqa/selenium/grid/node/ProxyNodeWebsockets.java @@ -17,7 +17,6 @@ package org.openqa.selenium.grid.node; -import static org.openqa.selenium.internal.Debug.getDebugLogLevel; import static org.openqa.selenium.remote.http.HttpMethod.GET; import io.netty.buffer.Unpooled; @@ -179,7 +178,7 @@ private Optional> findCdpEndpoint( } if (cdpUri.isPresent()) { - LOG.log(getDebugLogLevel(), String.format("Endpoint found in %s", cdpEndpointCap)); + LOG.log(Level.FINE, String.format("Endpoint found in %s", cdpEndpointCap)); return cdpUri.map(cdp -> createWsEndPoint(cdp, downstream, sessionConsumer, sessionId)); } else { try { @@ -244,7 +243,7 @@ private Optional> findVncEndpoint( LOG.warning("Invalid URI for endpoint " + vncLocalAddress); return Optional.empty(); } - LOG.log(getDebugLogLevel(), String.format("Endpoint found in %s", "se:vncLocalAddress")); + LOG.log(Level.FINE, String.format("Endpoint found in %s", "se:vncLocalAddress")); return vncUri.map(vnc -> createWsEndPoint(vnc, downstream, sessionConsumer, sessionId)); } diff --git a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java index d997c70dfd81b..463e7112a65c3 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -112,7 +112,6 @@ import org.openqa.selenium.grid.node.SessionFactory; import org.openqa.selenium.grid.node.config.NodeOptions; import org.openqa.selenium.grid.security.Secret; -import org.openqa.selenium.internal.Debug; import org.openqa.selenium.internal.Either; import org.openqa.selenium.internal.Require; import org.openqa.selenium.io.FileHandler; @@ -399,7 +398,7 @@ private void stopTimedOutSession( } } } else { - LOG.log(Debug.getDebugLogLevel(), "Received stop session notification with null values"); + LOG.log(Level.FINE, "Received stop session notification with null values"); span.setStatus(Status.INVALID_ARGUMENT); span.addEvent("Received stop session notification with null values", attributeMap); } @@ -1415,10 +1414,7 @@ private void checkSessionCount() { private boolean decrementSessionCount() { if (this.drainAfterSessions) { int remainingSessions = this.sessionCount.decrementAndGet(); - LOG.log( - Debug.getDebugLogLevel(), - "{0} remaining sessions before draining Node", - remainingSessions); + LOG.log(Level.FINE, "{0} remaining sessions before draining Node", remainingSessions); return remainingSessions >= 0; } return true; @@ -1432,7 +1428,7 @@ private void restoreSessionCount() { if (this.drainAfterSessions) { int remainingSessions = this.sessionCount.incrementAndGet(); LOG.log( - Debug.getDebugLogLevel(), + Level.FINE, "Session creation failed, restored count. {0} remaining sessions before draining Node", remainingSessions); } diff --git a/java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java b/java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java index 2d3eaa7cadc03..792dbdfc1417a 100644 --- a/java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java +++ b/java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java @@ -49,7 +49,6 @@ import org.openqa.selenium.grid.node.ActiveSession; import org.openqa.selenium.grid.node.DefaultActiveSession; import org.openqa.selenium.grid.node.SessionFactory; -import org.openqa.selenium.internal.Debug; import org.openqa.selenium.internal.Either; import org.openqa.selenium.internal.Require; import org.openqa.selenium.remote.CapabilityType; @@ -254,7 +253,7 @@ public boolean isServiceUp() { try (HttpClient client = clientFactory.createClient(clientConfig)) { HttpResponse response = client.execute(new HttpRequest(HttpMethod.GET, serviceStatusUrl.toString())); - LOG.log(Debug.getDebugLogLevel(), response::contentAsString); + LOG.log(Level.FINE, response::contentAsString); return response.getStatus() == 200; } catch (Exception e) { LOG.log( @@ -262,7 +261,7 @@ public boolean isServiceUp() { () -> String.format( "Error checking service status %s. %s", serviceStatusUrl, e.getMessage())); - LOG.log(Debug.getDebugLogLevel(), "Error checking service status " + serviceStatusUrl, e); + LOG.log(Level.FINE, "Error checking service status " + serviceStatusUrl, e); } return false; } diff --git a/java/src/org/openqa/selenium/netty/server/RequestConverter.java b/java/src/org/openqa/selenium/netty/server/RequestConverter.java index 4b98fe4ffa1f6..6084536a91c7a 100644 --- a/java/src/org/openqa/selenium/netty/server/RequestConverter.java +++ b/java/src/org/openqa/selenium/netty/server/RequestConverter.java @@ -38,9 +38,9 @@ import io.netty.util.ReferenceCountUtil; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; +import java.util.logging.Level; import java.util.logging.Logger; import org.jspecify.annotations.Nullable; -import org.openqa.selenium.internal.Debug; import org.openqa.selenium.remote.http.Contents; import org.openqa.selenium.remote.http.HttpMethod; import org.openqa.selenium.remote.http.HttpRequest; @@ -58,10 +58,10 @@ class RequestConverter extends SimpleChannelInboundHandler { @Override protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { - LOG.log(Debug.getDebugLogLevel(), "Incoming message: {0}", msg); + LOG.log(Level.FINE, "Incoming message: {0}", msg); if (msg instanceof io.netty.handler.codec.http.HttpRequest) { - LOG.log(Debug.getDebugLogLevel(), "Start of http request: {0}", msg); + LOG.log(Level.FINE, "Start of http request: {0}", msg); io.netty.handler.codec.http.HttpRequest nettyRequest = (io.netty.handler.codec.http.HttpRequest) msg; @@ -112,7 +112,7 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Ex } if (msg instanceof LastHttpContent) { - LOG.log(Debug.getDebugLogLevel(), "End of http request: {0}", msg); + LOG.log(Level.FINE, "End of http request: {0}", msg); if (buffer != null) { request.setContent( @@ -128,7 +128,7 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Ex @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { - LOG.log(Debug.getDebugLogLevel(), "Channel became inactive."); + LOG.log(Level.FINE, "Channel became inactive."); super.channelInactive(ctx); } @@ -172,8 +172,7 @@ private HttpRequest createRequest( } catch (Exception ignore) { ctx.writeAndFlush( new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST)); - LOG.log( - Debug.getDebugLogLevel(), "Not possible to decode parameters. {0}", nettyRequest.uri()); + LOG.log(Level.FINE, "Not possible to decode parameters. {0}", nettyRequest.uri()); return null; } } diff --git a/java/test/org/openqa/selenium/netty/server/RequestConverterTest.java b/java/test/org/openqa/selenium/netty/server/RequestConverterTest.java index 24c147dc0a75f..de4d66b018dd4 100644 --- a/java/test/org/openqa/selenium/netty/server/RequestConverterTest.java +++ b/java/test/org/openqa/selenium/netty/server/RequestConverterTest.java @@ -27,6 +27,12 @@ import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; import org.junit.jupiter.api.Test; import org.openqa.selenium.remote.http.HttpRequest; @@ -63,4 +69,50 @@ void returnsAnErrorForUnhandledMethods() { assertThat(res.status()).isEqualTo(HttpResponseStatus.METHOD_NOT_ALLOWED); } + + @Test + void requestLogsAtFine() { + Logger logger = Logger.getLogger(RequestConverter.class.getName()); + Level previousLevel = logger.getLevel(); + List records = new ArrayList<>(); + Handler handler = + new Handler() { + @Override + public void publish(LogRecord record) { + records.add(record); + } + + @Override + public void flush() {} + + @Override + public void close() {} + }; + logger.setLevel(Level.ALL); + logger.addHandler(handler); + try { + RequestConverter converter = new RequestConverter(); + EmbeddedChannel channel = new EmbeddedChannel(converter); + FullHttpRequest httpRequest = + new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/cheese"); + + assertThat(channel.writeInbound(httpRequest)).isTrue(); + + assertThat(records) + .filteredOn(record -> record.getMessage().startsWith("Incoming message")) + .isNotEmpty() + .allSatisfy(record -> assertThat(record.getLevel()).isEqualTo(Level.FINE)); + assertThat(records) + .filteredOn(record -> record.getMessage().startsWith("Start of http request")) + .isNotEmpty() + .allSatisfy(record -> assertThat(record.getLevel()).isEqualTo(Level.FINE)); + assertThat(records) + .filteredOn(record -> record.getMessage().startsWith("End of http request")) + .isNotEmpty() + .allSatisfy(record -> assertThat(record.getLevel()).isEqualTo(Level.FINE)); + } finally { + logger.removeHandler(handler); + logger.setLevel(previousLevel); + } + } }