Skip to content

Commit

Permalink
refactor: Update a few error messages to indicate the method they occ…
Browse files Browse the repository at this point in the history
…urred in
  • Loading branch information
nfelt14 committed Jan 16, 2025
1 parent 545b6fa commit 26f7982
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/tm_devices/driver_mixins/device_control/pi_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def query_binary(self, query: str, verbose: bool = True) -> Sequence[float]:

if not response:
pi_cmd_repr = (
f" for the following query: {query!r}" if self._verbose and verbose else ""
f" for the following binary query: {query!r}" if self._verbose and verbose else ""
)
msg = f"An empty string was returned from {self._name_and_alias}{pi_cmd_repr}"
_logger.error(msg)
Expand Down Expand Up @@ -553,7 +553,9 @@ def query_raw_binary(self, query: str, verbose: bool = True) -> bytes:

if not response.strip():
pi_cmd_repr = (
f" for the following query: {query!r}" if self._verbose and verbose else ""
f" for the following raw binary query: {query!r}"
if self._verbose and verbose
else ""
)
msg = f"An empty string was returned from {self._name_and_alias}{pi_cmd_repr}"
_logger.error(msg)
Expand Down
2 changes: 0 additions & 2 deletions src/tm_devices/helpers/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ def configure_logging( # pylint: disable=too-many-locals

if log_uncaught_exceptions and log_file_level != LoggingLevels.NONE:
sys.excepthook = __exception_handler
else:
sys.excepthook = sys.__excepthook__
_logger_initialized = True
return _logger

Expand Down
1 change: 1 addition & 0 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def test_configure_logger_full(reset_package_logger: None) -> None: # noqa: ARG

assert not any(isinstance(handler, logging.FileHandler) for handler in pyvisa.logger.handlers)
assert len(logging.getLogger(PACKAGE_NAME).handlers) == 0 # pylint: disable=use-implicit-booleaness-not-comparison-to-zero
sys.excepthook = sys.__excepthook__
logger = configure_logging(
log_console_level="DEBUG",
log_file_level="DEBUG",
Expand Down

0 comments on commit 26f7982

Please sign in to comment.