From 7695e447981bfee72ff52c4f2a25429bd66907b8 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Sun, 22 Sep 2024 20:16:31 +0200 Subject: [PATCH 1/2] duplicate line --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4c3bbba50..2f255f301 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,6 @@ classifiers = [ "Operating System :: OS Independent", "Operating System :: Microsoft", "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", From b3350dfc8c7f463bf4bc88607934d11a527d493d Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Sun, 22 Sep 2024 20:16:38 +0200 Subject: [PATCH 2/2] Logging: add stacklevel=2 Without this argument the location of the logging code is broken. (available since Python 3.8) --- pymodbus/logging.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pymodbus/logging.py b/pymodbus/logging.py index aec7e0599..764eab215 100644 --- a/pymodbus/logging.py +++ b/pymodbus/logging.py @@ -94,28 +94,28 @@ def build_msg(cls, txt, *args): def info(cls, txt, *args): """Log info messages.""" if cls._logger.isEnabledFor(logging.INFO): - cls._logger.info(cls.build_msg(txt, *args)) + cls._logger.info(cls.build_msg(txt, *args), stacklevel=2) @classmethod def debug(cls, txt, *args): """Log debug messages.""" if cls._logger.isEnabledFor(logging.DEBUG): - cls._logger.debug(cls.build_msg(txt, *args)) + cls._logger.debug(cls.build_msg(txt, *args), stacklevel=2) @classmethod def warning(cls, txt, *args): """Log warning messages.""" if cls._logger.isEnabledFor(logging.WARNING): - cls._logger.warning(cls.build_msg(txt, *args)) + cls._logger.warning(cls.build_msg(txt, *args), stacklevel=2) @classmethod def error(cls, txt, *args): """Log error messages.""" if cls._logger.isEnabledFor(logging.ERROR): - cls._logger.error(cls.build_msg(txt, *args)) + cls._logger.error(cls.build_msg(txt, *args), stacklevel=2) @classmethod def critical(cls, txt, *args): """Log critical messages.""" if cls._logger.isEnabledFor(logging.CRITICAL): - cls._logger.critical(cls.build_msg(txt, *args)) + cls._logger.critical(cls.build_msg(txt, *args), stacklevel=2)