Skip to content

Commit 971a727

Browse files
titusfortnerdiemol
andauthored
[java] make all logging variable names consistent (#12007)
* [java] make all logging variable names consistent * [java] Formatting files --------- Co-authored-by: Diego Molina <[email protected]>
1 parent 4bf1d68 commit 971a727

21 files changed

Lines changed: 84 additions & 84 deletions

java/src/org/openqa/selenium/devtools/DevTools.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import org.openqa.selenium.internal.Require;
3939

4040
public class DevTools implements Closeable {
41-
private static final Logger log = Logger.getLogger(DevTools.class.getName());
41+
private static final Logger LOG = Logger.getLogger(DevTools.class.getName());
4242

4343
private final Domains protocol;
4444
private final Duration timeout = Duration.ofSeconds(10);
@@ -71,7 +71,7 @@ public void disconnectSession() {
7171
timeout);
7272
} catch (Exception e) {
7373
// Exceptions should not prevent closing the connection and the web driver
74-
log.warning("Exception while detaching from target: " + e.getMessage());
74+
LOG.warning("Exception while detaching from target: " + e.getMessage());
7575
}
7676
}
7777
}
@@ -143,7 +143,7 @@ public void createSession(String windowHandle) {
143143
.send(cdpSession, getDomains().log().clear())
144144
.exceptionally(
145145
t -> {
146-
log.log(Level.SEVERE, t.getMessage(), t);
146+
LOG.log(Level.SEVERE, t.getMessage(), t);
147147
return null;
148148
}))
149149
.get(timeout.toMillis(), MILLISECONDS);

java/src/org/openqa/selenium/net/HostIdentifier.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.openqa.selenium.Platform;
3131

3232
public class HostIdentifier {
33-
private static final Logger log = Logger.getLogger(HostIdentifier.class.getName());
33+
private static final Logger LOG = Logger.getLogger(HostIdentifier.class.getName());
3434

3535
private static volatile String hostName;
3636
private static volatile String hostAddress;
@@ -60,12 +60,12 @@ private static String resolveHostName() {
6060
}
6161
}
6262
} catch (InterruptedException e) {
63-
log.log(WARNING, "Failed to resolve host name", e);
63+
LOG.log(WARNING, "Failed to resolve host name", e);
6464
Thread.currentThread().interrupt();
6565
throw new RuntimeException(e);
6666
} catch (Throwable e) {
6767
// fall through
68-
log.log(WARNING, "Failed to resolve host name", e);
68+
LOG.log(WARNING, "Failed to resolve host name", e);
6969
}
7070
}
7171
if (host == null) {
@@ -74,7 +74,7 @@ private static String resolveHostName() {
7474
host = InetAddress.getLocalHost().getHostName();
7575
} catch (Throwable e) {
7676
host = "Unknown"; // At least we tried.
77-
log.log(WARNING, "Failed to resolve host name", e);
77+
LOG.log(WARNING, "Failed to resolve host name", e);
7878
}
7979
}
8080

@@ -95,7 +95,7 @@ private static String resolveHostAddress() {
9595
}
9696
} catch (Throwable e) {
9797
// Fall through and go the slow way.
98-
log.log(WARNING, "Failed to resolve host address", e);
98+
LOG.log(WARNING, "Failed to resolve host address", e);
9999
}
100100
}
101101
if (address == null) {
@@ -104,7 +104,7 @@ private static String resolveHostAddress() {
104104
address = InetAddress.getLocalHost().getHostAddress();
105105
} catch (Throwable e) {
106106
address = "Unknown";
107-
log.log(WARNING, "Failed to resolve host address", e);
107+
LOG.log(WARNING, "Failed to resolve host address", e);
108108
}
109109
}
110110

java/src/org/openqa/selenium/net/NetworkInterface.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.stream.StreamSupport;
3232

3333
public class NetworkInterface {
34+
private static final Logger LOG = Logger.getLogger(NetworkInterface.class.getName());
3435

3536
private final String name;
3637
private java.net.NetworkInterface networkInterface;
@@ -65,7 +66,7 @@ public boolean isLoopBack() {
6566
// from java.net.NetworkInterface API
6667
isLoopback = networkInterface.isLoopback();
6768
} catch (SocketException ex) {
68-
Logger.getLogger(NetworkInterface.class.getName()).log(Level.WARNING, null, ex);
69+
LOG.log(Level.WARNING, null, ex);
6970
// If a SocketException is caught, determine whether this NetworkInterface
7071
// instance is loopback from computation from its inetAddresses
7172
isLoopback = isLoopBackFromINetAddresses(list(networkInterface.getInetAddresses()));

java/src/org/openqa/selenium/net/UrlChecker.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/** Polls a URL until a HTTP 200 response is received. */
3636
public class UrlChecker {
3737

38-
private static final Logger log = Logger.getLogger(UrlChecker.class.getName());
38+
private static final Logger LOG = Logger.getLogger(UrlChecker.class.getName());
3939

4040
static final int CONNECT_TIMEOUT_MS = 500;
4141
private static final int READ_TIMEOUT_MS = 1000;
@@ -56,7 +56,7 @@ public class UrlChecker {
5656
public void waitUntilAvailable(long timeout, TimeUnit unit, final URL... urls)
5757
throws TimeoutException {
5858
long start = System.nanoTime();
59-
log.fine("Waiting for " + Arrays.toString(urls));
59+
LOG.fine("Waiting for " + Arrays.toString(urls));
6060
try {
6161
Future<Void> callback =
6262
EXECUTOR.submit(
@@ -70,7 +70,7 @@ public void waitUntilAvailable(long timeout, TimeUnit unit, final URL... urls)
7070
}
7171
for (URL url : urls) {
7272
try {
73-
log.fine("Polling " + url);
73+
LOG.fine("Polling " + url);
7474
connection = connectToUrl(url);
7575
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
7676
return null;
@@ -106,7 +106,7 @@ public void waitUntilAvailable(long timeout, TimeUnit unit, final URL... urls)
106106
public void waitUntilUnavailable(long timeout, TimeUnit unit, final URL url)
107107
throws TimeoutException {
108108
long start = System.nanoTime();
109-
log.fine("Waiting for " + url);
109+
LOG.fine("Waiting for " + url);
110110
try {
111111
Future<Void> callback =
112112
EXECUTOR.submit(
@@ -116,7 +116,7 @@ public void waitUntilUnavailable(long timeout, TimeUnit unit, final URL url)
116116
long sleepMillis = MIN_POLL_INTERVAL_MS;
117117
while (true) {
118118
try {
119-
log.fine("Polling " + url);
119+
LOG.fine("Polling " + url);
120120
connection = connectToUrl(url);
121121
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
122122
return null;

java/src/org/openqa/selenium/os/OsProcess.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import org.openqa.selenium.io.MultiOutputStream;
4646

4747
class OsProcess {
48-
private static final Logger log = Logger.getLogger(OsProcess.class.getName());
48+
private static final Logger LOG = Logger.getLogger(OsProcess.class.getName());
4949

5050
private final CircularOutputStream inputOut = new CircularOutputStream(32768);
5151
private volatile String allInput;
@@ -132,7 +132,7 @@ public int destroy() {
132132
watchdog.waitForTerminationAfterDestroy(1, SECONDS);
133133
}
134134
} else {
135-
log.warning("Tried to destory a process which never started.");
135+
LOG.warning("Tried to destory a process which never started.");
136136
}
137137

138138
// Make a best effort to drain the streams.
@@ -144,7 +144,7 @@ public int destroy() {
144144
streamHandler.stop();
145145
} catch (IOException e) {
146146
// Ignore and destroy the process anyway.
147-
log.log(
147+
LOG.log(
148148
Level.INFO,
149149
"Unable to drain process streams. Ignoring but the exception being swallowed follows.",
150150
e);
@@ -155,7 +155,7 @@ public int destroy() {
155155
return getExitCode();
156156
}
157157

158-
log.severe(String.format("Unable to kill process %s", watchdog.process));
158+
LOG.severe(String.format("Unable to kill process %s", watchdog.process));
159159
int exitCode = -1;
160160
executor.setExitValue(exitCode);
161161
return exitCode;
@@ -199,7 +199,7 @@ public int getExitCode() {
199199

200200
public void checkForError() {
201201
if (handler.getException() != null) {
202-
log.severe(handler.getException().toString());
202+
LOG.severe(handler.getException().toString());
203203
}
204204
}
205205

java/src/org/openqa/selenium/remote/AddHasAuthentication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
public class AddHasAuthentication implements AugmenterProvider<HasAuthentication> {
3434

35-
private static final Logger logger = Logger.getLogger(AddHasAuthentication.class.getName());
35+
private static final Logger LOG = Logger.getLogger(AddHasAuthentication.class.getName());
3636
private static final Predicate<String> IS_CHROMIUM_BROWSER =
3737
name -> CHROME.is(name) || EDGE.is(name) || OPERA.is(name);
3838

java/src/org/openqa/selenium/remote/ErrorCodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class ErrorCodes {
9393
// The following error codes are derived straight from HTTP return codes.
9494
public static final int METHOD_NOT_ALLOWED = 405;
9595

96-
private static final Logger log = Logger.getLogger(ErrorCodes.class.getName());
96+
private static final Logger LOG = Logger.getLogger(ErrorCodes.class.getName());
9797
// Every row on this table should be self-explanatory, except for the two booleans at the end.
9898
// The first of these is "isCanonicalJsonCodeForException". This means that when doing the mapping
9999
// for a JSON Wire Protocol status code, this KnownError provides the exception that should be
@@ -368,7 +368,7 @@ public int toStatus(String webdriverState, Optional<Integer> httpStatus) {
368368
}
369369
KnownError error = possibleMatches.get(0);
370370
if (httpStatus.isPresent() && httpStatus.get() != error.getW3cHttpStatus()) {
371-
log.info(
371+
LOG.info(
372372
String.format(
373373
"HTTP Status: '%d' -> incorrect JSON status mapping for '%s' (%d expected)",
374374
httpStatus.get(), webdriverState, error.getW3cHttpStatus()));

java/src/org/openqa/selenium/remote/LocalFileDetector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/** Detects files on the local disk. */
2424
public class LocalFileDetector implements FileDetector {
2525

26-
private static final Logger log = Logger.getLogger(LocalFileDetector.class.getName());
26+
private static final Logger LOG = Logger.getLogger(LocalFileDetector.class.getName());
2727

2828
@Override
2929
public File getLocalFile(CharSequence... keys) {
@@ -48,7 +48,7 @@ public File getLocalFile(CharSequence... keys) {
4848
}
4949
File toUpload = new File(parentDir, file.getName());
5050

51-
log.fine("Detected local file: " + toUpload.exists());
51+
LOG.fine("Detected local file: " + toUpload.exists());
5252

5353
return toUpload.exists() && toUpload.isFile() ? toUpload : null;
5454
}

java/src/org/openqa/selenium/remote/RemoteLogs.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class RemoteLogs implements Logs {
4242
private static final String TIMESTAMP = "timestamp";
4343
private static final String MESSAGE = "message";
4444

45-
private static final Logger logger = Logger.getLogger(RemoteLogs.class.getName());
45+
private static final Logger LOG = Logger.getLogger(RemoteLogs.class.getName());
4646

4747
protected ExecuteMethod executeMethod;
4848

@@ -63,8 +63,7 @@ public LogEntries get(String logType) {
6363
} catch (WebDriverException e) {
6464
// An exception may be thrown if the WebDriver server does not recognize profiler logs.
6565
// In this case, the user should be able to see the local profiler logs.
66-
logger.log(
67-
Level.WARNING, "Remote profiler logs are not available and have been omitted.", e);
66+
LOG.log(Level.WARNING, "Remote profiler logs are not available and have been omitted.", e);
6867
}
6968

7069
return LogCombiner.combine(remoteEntries, getLocalEntries(logType));

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ public class RemoteWebDriver
103103
PrintsPage,
104104
TakesScreenshot {
105105

106-
// TODO: This static logger should be unified with the per-instance localLogs
107-
private static final Logger logger = Logger.getLogger(RemoteWebDriver.class.getName());
106+
private static final Logger LOG = Logger.getLogger(RemoteWebDriver.class.getName());
108107
private final ElementLocation elementLocation = new ElementLocation();
109108
private Level level = Level.FINE;
110109
private ErrorHandler errorHandler = new ErrorHandler();
@@ -196,7 +195,7 @@ public static RemoteWebDriverBuilder builder() {
196195
private Capabilities init(Capabilities capabilities) {
197196
capabilities = capabilities == null ? new ImmutableCapabilities() : capabilities;
198197

199-
logger.addHandler(LoggingHandler.getInstance());
198+
LOG.addHandler(LoggingHandler.getInstance());
200199

201200
converter = new JsonToWebElementConverter(this);
202201
executeMethod = new RemoteExecuteMethod(this);
@@ -412,7 +411,7 @@ public void close() {
412411
try {
413412
((HasDevTools) this).maybeGetDevTools().ifPresent(DevTools::disconnectSession);
414413
} catch (ConnectionFailedException unableToEstablishWebsocketConnection) {
415-
logger.log(
414+
LOG.log(
416415
SEVERE, "Failed to disconnect DevTools session", unableToEstablishWebsocketConnection);
417416
}
418417
}
@@ -532,7 +531,7 @@ protected void setElementConverter(JsonToWebElementConverter converter) {
532531
*/
533532
public void setLogLevel(Level level) {
534533
this.level = level;
535-
logger.setLevel(level);
534+
LOG.setLevel(level);
536535
}
537536

538537
protected Response execute(CommandPayload payload) {
@@ -649,7 +648,7 @@ public void removeVirtualAuthenticator(VirtualAuthenticator authenticator) {
649648
* @param when verb tense of "Execute" to prefix message
650649
*/
651650
protected void log(SessionId sessionId, String commandName, Object toLog, When when) {
652-
if (!logger.isLoggable(level)) {
651+
if (!LOG.isLoggable(level)) {
653652
return;
654653
}
655654
String text = String.valueOf(toLog);
@@ -672,16 +671,16 @@ protected void log(SessionId sessionId, String commandName, Object toLog, When w
672671
}
673672
switch (when) {
674673
case BEFORE:
675-
logger.log(level, "Executing: " + commandName + " " + text);
674+
LOG.log(level, "Executing: " + commandName + " " + text);
676675
break;
677676
case AFTER:
678-
logger.log(level, "Executed: " + commandName + " " + text);
677+
LOG.log(level, "Executed: " + commandName + " " + text);
679678
break;
680679
case EXCEPTION:
681-
logger.log(level, "Exception: " + commandName + " " + text);
680+
LOG.log(level, "Exception: " + commandName + " " + text);
682681
break;
683682
default:
684-
logger.log(level, text);
683+
LOG.log(level, text);
685684
break;
686685
}
687686
}
@@ -694,7 +693,7 @@ private void checkNonW3CCapabilities(Capabilities capabilities) {
694693
.collect(Collectors.toList());
695694

696695
if (!invalid.isEmpty()) {
697-
logger.log(
696+
LOG.log(
698697
Level.WARNING,
699698
() ->
700699
String.format(

0 commit comments

Comments
 (0)