From 3cc510ca0782c26b35abb9f83e10fc2740a8d2e9 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Mon, 23 Sep 2024 10:35:05 +0200 Subject: [PATCH] Add `stacklevel=2` to logging functions (#2330) --- pymodbus/logging.py | 10 +++++----- pyproject.toml | 1 - 2 files changed, 5 insertions(+), 6 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) 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",