Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions java/src/org/openqa/selenium/chrome/ChromeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ protected void loadSystemProperties() {
}
if (Debug.isDebugAll()
|| (verbose == null && Boolean.getBoolean(CHROME_DRIVER_VERBOSE_LOG_PROPERTY))) {
if (Debug.isDebugAll()
&& (logLevel != null
|| silent != null
|| Boolean.getBoolean(CHROME_DRIVER_SILENT_OUTPUT_PROPERTY)
|| System.getProperty(CHROME_DRIVER_LOG_LEVEL_PROPERTY) != null)) {
System.err.println(
"WARNING: Environment Variable `SE_DEBUG` is set; forcing ChromeDriver --verbose and"
+ " overriding --silent/--log-level settings.");
}
withVerbose(true);
}
if (silent == null && Boolean.getBoolean(CHROME_DRIVER_SILENT_OUTPUT_PROPERTY)) {
Expand Down
9 changes: 9 additions & 0 deletions java/src/org/openqa/selenium/edge/EdgeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ protected void loadSystemProperties() {
}
if (Debug.isDebugAll()
|| (verbose == null && Boolean.getBoolean(EDGE_DRIVER_VERBOSE_LOG_PROPERTY))) {
if (Debug.isDebugAll()
&& (logLevel != null
|| silent != null
|| Boolean.getBoolean(EDGE_DRIVER_SILENT_OUTPUT_PROPERTY)
|| System.getProperty(EDGE_DRIVER_LOG_LEVEL_PROPERTY) != null)) {
System.err.println(
"WARNING: Environment Variable `SE_DEBUG` is set; forcing EdgeDriver --verbose and"
+ " overriding --silent/--log-level settings.");
}
withVerbose(true);
}
if (silent == null && Boolean.getBoolean(EDGE_DRIVER_SILENT_OUTPUT_PROPERTY)) {
Expand Down
5 changes: 5 additions & 0 deletions java/src/org/openqa/selenium/firefox/GeckoDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ public GeckoDriverService.Builder withWebSocketPort(@Nullable Integer websocketP
protected void loadSystemProperties() {
parseLogOutput(GECKO_DRIVER_LOG_PROPERTY);
if (Debug.isDebugAll()) {
if (logLevel != null || System.getProperty(GECKO_DRIVER_LOG_LEVEL_PROPERTY) != null) {
System.err.println(
"WARNING: Environment Variable `SE_DEBUG` is set; forcing GeckoDriver log level to"
+ " DEBUG and overriding configured log level.");
}
logLevel = FirefoxDriverLogLevel.DEBUG;
} else if (logLevel == null) {
logLevel =
Expand Down
8 changes: 8 additions & 0 deletions java/src/org/openqa/selenium/grid/log/LoggingOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public String getLogEncoding() {
public void setLoggingLevel() {
String configLevel = config.get(LOGGING_SECTION, "log-level").orElse(DEFAULT_LOG_LEVEL);
if (Debug.isDebugAll()) {
System.err.println(
"WARNING: Environment Variable `SE_DEBUG` is set; forcing Grid log level to FINE and"
+ " overriding configured log level.");
configLevel = Level.FINE.getName();
}

Expand Down Expand Up @@ -183,6 +186,11 @@ private void configureLogEncoding(Logger logger, String encoding, Handler handle
}

private OutputStream getOutputStream() {
if (Debug.isDebugAll() && config.get(LOGGING_SECTION, "log-file").isEmpty()) {
System.err.println(
"WARNING: Environment Variable `SE_DEBUG` is set; defaulting Grid log output to stderr"
+ " instead of stdout.");
}
return config
.get(LOGGING_SECTION, "log-file")
.map(
Expand Down
11 changes: 10 additions & 1 deletion java/src/org/openqa/selenium/internal/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.openqa.selenium.internal;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
Expand All @@ -26,6 +27,7 @@
public class Debug {

private static final boolean IS_DEBUG;
private static final AtomicBoolean DEBUG_WARNING_LOGGED = new AtomicBoolean(false);
private static boolean loggerConfigured = false;
private static Logger seleniumLogger;

Expand All @@ -47,7 +49,14 @@ public static Level getDebugLogLevel() {
}

public static boolean isDebugAll() {
return Boolean.parseBoolean(System.getenv("SE_DEBUG"));
boolean everything = Boolean.parseBoolean(System.getenv("SE_DEBUG"));
if (everything && DEBUG_WARNING_LOGGED.compareAndSet(false, true)) {
String warn =
"WARNING: Environment Variable `SE_DEBUG` is set; Selenium is forcing verbose logging"
+ " which may override user-specified settings.";
System.err.println(warn);
}
return everything;
}

public static void configureLogger() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ protected void parseLogOutput(String logProperty) {

String defaultLocation = Debug.isDebugAll() ? LOG_STDERR : LOG_NULL;
String logLocation = System.getProperty(logProperty, defaultLocation);
if (Debug.isDebugAll() && System.getProperty(logProperty) == null) {
System.err.println(
"WARNING: Environment Variable `SE_DEBUG` is set; defaulting driver log output to"
+ " stderr.");
}
switch (logLocation) {
case LOG_STDOUT:
withLogOutput(System.out);
Expand Down
5 changes: 5 additions & 0 deletions javascript/selenium-webdriver/lib/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ const logManager = new LogManager()
if (typeof process !== 'undefined' && process.env && (process.env.SE_DEBUG || process.env.SELENIUM_VERBOSE)) {
logManager.root_.setLevel(Level.ALL)
logManager.root_.addHandler(consoleHandler)
if (process.env.SE_DEBUG) {
logManager.root_.warning(
'Environment Variable `SE_DEBUG` is set; Selenium is forcing verbose logging which may override user-specified settings.',
)
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions py/selenium/webdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
logger.setLevel(logging.DEBUG)
if not logger.handlers:
logger.addHandler(logging.StreamHandler())
logger.warning(
"Environment Variable `SE_DEBUG` is set; "
"Selenium is forcing verbose logging which may override user-specified settings."
)

from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.chrome.service import Service as ChromeService
Expand Down
15 changes: 12 additions & 3 deletions py/selenium/webdriver/chromium/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
import sys
from collections.abc import Mapping, Sequence
Expand Down Expand Up @@ -55,9 +56,17 @@ def __init__(
self.log_output = log_output

if os.environ.get("SE_DEBUG"):
self._service_args = [
arg for arg in self._service_args if not any(x in arg for x in ("log-level", "log-path", "silent"))
]
has_arg_conflicts = any(x in arg for arg in self._service_args for x in ("log-level", "log-path", "silent"))
has_output_conflict = self.log_output is not None
if has_arg_conflicts or has_output_conflict:
logging.getLogger(__name__).warning(
"Environment Variable `SE_DEBUG` is set; "
"forcing ChromiumDriver --verbose and overriding log-level/log-output/silent settings."
)
if has_arg_conflicts:
self._service_args = [
arg for arg in self._service_args if not any(x in arg for x in ("log-level", "log-path", "silent"))
]
self._service_args.append("--verbose")
self.log_output = sys.stderr

Expand Down
19 changes: 14 additions & 5 deletions py/selenium/webdriver/firefox/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
import sys
from collections.abc import Mapping, Sequence
Expand Down Expand Up @@ -49,11 +50,19 @@ def __init__(
driver_path_env_key = driver_path_env_key or "SE_GECKODRIVER"

if os.environ.get("SE_DEBUG"):
if "--log" in self._service_args:
idx = self._service_args.index("--log")
del self._service_args[idx : idx + 2]
else:
self._service_args = [arg for arg in self._service_args if not arg.startswith("--log=")]
has_log_arg = "--log" in self._service_args or any(arg.startswith("--log=") for arg in self._service_args)
has_output_conflict = log_output is not None
if has_log_arg or has_output_conflict:
logging.getLogger(__name__).warning(
"Environment Variable `SE_DEBUG` is set; "
"forcing GeckoDriver log level to DEBUG and overriding configured log level/output."
)
if has_log_arg:
if "--log" in self._service_args:
idx = self._service_args.index("--log")
del self._service_args[idx : idx + 2]
else:
self._service_args = [arg for arg in self._service_args if not arg.startswith("--log=")]
self._service_args.append("--log")
self._service_args.append("debug")
log_output = sys.stderr
Expand Down
15 changes: 12 additions & 3 deletions py/selenium/webdriver/ie/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.

import logging
import os
import sys
from collections.abc import Sequence
Expand Down Expand Up @@ -58,9 +59,17 @@ def __init__(
self._service_args.append(f"--log-level={log_level}")

if os.environ.get("SE_DEBUG"):
self._service_args = [
arg for arg in self._service_args if not any(x in arg for x in ("log-level", "log-file"))
]
has_arg_conflicts = any(x in arg for arg in self._service_args for x in ("log-level", "log-file"))
has_output_conflict = log_output is not None
if has_arg_conflicts or has_output_conflict:
logging.getLogger(__name__).warning(
"Environment Variable `SE_DEBUG` is set; "
"forcing IEDriver log level to DEBUG and overriding configured log level/output."
)
if has_arg_conflicts:
self._service_args = [
arg for arg in self._service_args if not any(x in arg for x in ("log-level", "log-file"))
]
self._service_args.append("--log-level=DEBUG")
log_output = sys.stderr

Expand Down
Loading