diff --git a/pyvisa_py/__init__.py b/pyvisa_py/__init__.py index 5abeb937..d0dee68a 100644 --- a/pyvisa_py/__init__.py +++ b/pyvisa_py/__init__.py @@ -7,17 +7,12 @@ """ -import logging from importlib.metadata import PackageNotFoundError, version # we need to import so that __init_subclass__() is executed once (hence the noqa) from . import attributes # noqa: F401 from .highlevel import PyVisaLibrary -# Global pyvisa-py logger used to provide more details on errors (VISA error code -# can make some report rather terse). -LOGGER = logging.getLogger("pyvisa.pyvisa-py") - __version__ = "unknown" try: __version__ = version(__name__) diff --git a/pyvisa_py/tcpip.py b/pyvisa_py/tcpip.py index be4c1446..bde43bae 100644 --- a/pyvisa_py/tcpip.py +++ b/pyvisa_py/tcpip.py @@ -18,7 +18,7 @@ from pyvisa import attributes, constants, errors, rname from pyvisa.constants import BufferOperation, ResourceAttribute, StatusCode -from . import LOGGER, common +from . import common from .protocols import hislip, rpc, vxi11 from .sessions import OpenError, Session, UnknownAttribute, VISARMSession @@ -149,7 +149,7 @@ def after_parsing(self) -> None: sub_address=sub_address, ) except OSError as e: - LOGGER.exception( + common.logger.exception( f"Failed to open HiSLIP connection to {self.parsed.host_address} " f"on port {port} with lan device name {sub_address}" ) @@ -490,7 +490,7 @@ def after_parsing(self) -> None: try: self.interface = Vxi11CoreClient(host_address, port, self.open_timeout) except rpc.RPCError: - LOGGER.exception( + common.logger.exception( f"Failed to open VX11 connection to {host_address} on port {port}" ) raise OpenError() @@ -522,7 +522,7 @@ def close(self) -> StatusCode: try: self.interface.destroy_link(self.link) except (errors.VisaIOError, socket.error, rpc.RPCError) as e: - LOGGER.error("Error closing VISA link: {}".format(e)) + common.logger.error("Error closing VISA link: {}".format(e)) self.interface.close() self.link = 0 @@ -886,7 +886,7 @@ def after_parsing(self) -> None: self.parsed.host_address, port, timeout=self.timeout ) except OSError as e: - LOGGER.exception( + common.logger.exception( f"Failed to open VICP connection to {self.parsed.host_address} " f"on port {port}" )