Skip to content

Commit

Permalink
[py]: use lazy string interpolation for logging calls
Browse files Browse the repository at this point in the history
  • Loading branch information
symonk committed Oct 2, 2023
1 parent d66108a commit 2ffb772
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions py/selenium/webdriver/common/bidi/cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def import_devtools(ver):
versions = tuple(f.name for f in devtools_path.iterdir() if f.is_dir())
latest = max(int(x[1:]) for x in versions)
selenium_logger = logging.getLogger(__name__)
selenium_logger.debug(f"Falling back to loading `devtools`: v{latest}")
selenium_logger.debug("Falling back to loading `devtools`: v%s", latest)
devtools = importlib.import_module(f"{base}{latest}")
return devtools

Expand Down Expand Up @@ -265,7 +265,7 @@ def _handle_cmd_response(self, data):
try:
cmd, event = self.inflight_cmd.pop(cmd_id)
except KeyError:
logger.warning(f"Got a message with a command ID that does not exist: {data}")
logger.warning("Got a message with a command ID that does not exist: %s", data)
return
if "error" in data:
# If the server reported an error, convert it to an exception and do
Expand Down
8 changes: 4 additions & 4 deletions py/selenium/webdriver/common/selenium_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def get_binary() -> Path:
if not path.is_file() and os.environ["CONDA_PREFIX"]:
# conda has a separate package selenium-manager, installs in bin
path = Path(os.path.join(os.environ["CONDA_PREFIX"], "bin", file))
logger.debug(f"Conda environment detected, using `{path}`")
logger.debug("Conda environment detected, using `%s`", path)
if not path.is_file():
raise WebDriverException(f"Unable to obtain working Selenium Manager binary; {path}")

logger.debug(f"Selenium Manager binary found at: {path}")
logger.debug("Selenium Manager binary found at: %s", path)

return path

Expand Down Expand Up @@ -99,7 +99,7 @@ def driver_location(self, options: BaseOptions) -> str:

browser_path = output["browser_path"]
driver_path = output["driver_path"]
logger.debug(f"Using driver at: {driver_path}")
logger.debug("Using driver at: %s", driver_path)

if hasattr(options.__class__, "binary_location"):
options.binary_location = browser_path
Expand All @@ -121,7 +121,7 @@ def run(args: List[str]) -> dict:
args.append("json")

command = " ".join(args)
logger.debug(f"Executing process: {command}")
logger.debug("Executing process: %s", command)
try:
if sys.platform == "win32":
completed_proc = subprocess.run(args, capture_output=True, creationflags=subprocess.CREATE_NO_WINDOW)
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _start_process(self, path: str) -> None:
startupinfo=start_info,
**self.popen_kw,
)
logger.debug(f"Started executable: `{self._path}` in a child process with pid: {self.process.pid}")
logger.debug("Started executable: `%s` in a child process with pid: %s", self._path, self.process.pid)
except TypeError:
raise
except OSError as err:
Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _request(self, method, url, body=None):
:Returns:
A dictionary with the server's parsed JSON response.
"""
LOGGER.debug(f"{method} {url} {body}")
LOGGER.debug("%s %s %s", method, url, body)
parsed_url = parse.urlparse(url)
headers = self.get_remote_connection_headers(parsed_url, self.keep_alive)
response = None
Expand All @@ -323,7 +323,7 @@ def _request(self, method, url, body=None):
response = http.request(method, url, body=body, headers=headers)
statuscode = response.status
data = response.data.decode("UTF-8")
LOGGER.debug(f"Remote response: status={response.status} | data={data} | headers={response.headers}")
LOGGER.debug("Remote response: status=%s | data=%s | headers=%s", response.status, data, response.headers)
try:
if 300 <= statuscode < 304:
return self._request("GET", response.headers.get("location", None))
Expand Down

0 comments on commit 2ffb772

Please sign in to comment.