From 5b9596bb02c08b1f1718c0db60b168090ee10645 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 18 Nov 2024 16:57:42 +0000 Subject: [PATCH] Use logging instead of print (#116) --- pyproject.toml | 1 - src/tox_extra/bindep.py | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b04b894..5a9f181 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,7 +119,6 @@ ignore = [ "S605", "S607", "SIM117", - "T201", "UP022" ] select = ["ALL"] diff --git a/src/tox_extra/bindep.py b/src/tox_extra/bindep.py index b35248d..5b455eb 100644 --- a/src/tox_extra/bindep.py +++ b/src/tox_extra/bindep.py @@ -2,6 +2,7 @@ from __future__ import annotations +import logging import os import subprocess import sys @@ -12,6 +13,8 @@ from collections.abc import Iterable from pathlib import Path +logger = logging.getLogger(__name__) + @cache def check_bindep(path: Path, profiles: Iterable[str] | None = None) -> None: @@ -32,12 +35,13 @@ def check_bindep(path: Path, profiles: Iterable[str] | None = None) -> None: cwd=path, ) if result.returncode: - print( + msg = ( f"Running '{' '.join(cmd)}' returned {result.returncode}, " - "likely missing system dependencies.", + "likely missing system dependencies." ) if result.stdout: - print(result.stdout) + msg += "\nstdout:\n" + result.stdout if result.stderr: - print(result.stderr, file=sys.stderr) + msg += "\nstderr:\n" + result.stderr + logger.error(msg) raise SystemExit(result.returncode)