Skip to content

Commit

Permalink
[java] let TracedCommandExecutor delegate NeedsLocalLogs calls
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 committed Jun 3, 2024
1 parent 2ad5abd commit 53ed43c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ private Capabilities init(Capabilities capabilities) {
converter = new JsonToWebElementConverter(this);
executeMethod = new RemoteExecuteMethod(this);

Set<String> logTypesToInclude = Set.of();
Set<String> logTypesToIgnore = Set.of();

LocalLogs performanceLogger = LocalLogs.getStoringLoggerInstance(logTypesToInclude);
LocalLogs performanceLogger = LocalLogs.getStoringLoggerInstance(logTypesToIgnore);
LocalLogs clientLogs =
LocalLogs.getHandlerBasedLoggerInstance(LoggingHandler.getInstance(), logTypesToInclude);
LocalLogs.getHandlerBasedLoggerInstance(LoggingHandler.getInstance(), logTypesToIgnore);
localLogs = LocalLogs.getCombinedLogsHolder(clientLogs, performanceLogger);
remoteLogs = new RemoteLogs(executeMethod, localLogs);

Expand Down
11 changes: 10 additions & 1 deletion java/src/org/openqa/selenium/remote/TracedCommandExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import org.openqa.selenium.logging.LocalLogs;
import org.openqa.selenium.logging.NeedsLocalLogs;
import org.openqa.selenium.remote.tracing.Span;
import org.openqa.selenium.remote.tracing.Tracer;

public class TracedCommandExecutor implements CommandExecutor {
public class TracedCommandExecutor implements CommandExecutor, NeedsLocalLogs {

private final CommandExecutor delegate;
private final Tracer tracer;
Expand Down Expand Up @@ -51,4 +53,11 @@ public Response execute(Command command) throws IOException {
return delegate.execute(command);
}
}

@Override
public void setLocalLogs(LocalLogs logs) {
if (delegate instanceof NeedsLocalLogs) {
((NeedsLocalLogs) delegate).setLocalLogs(logs);
}
}
}

0 comments on commit 53ed43c

Please sign in to comment.