From 65a3d8a1f5f5fbd016493bacebeba3b6222f066c Mon Sep 17 00:00:00 2001 From: Doug Wegscheid Date: Tue, 23 Sep 2025 11:21:45 -0400 Subject: [PATCH 1/2] Add module-level .log functions. --- adafruit_logging.py | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/adafruit_logging.py b/adafruit_logging.py index 5aba5f4..ac0dc19 100644 --- a/adafruit_logging.py +++ b/adafruit_logging.py @@ -617,3 +617,51 @@ def exception(self, err: Exception) -> None: # so we can't add the indent in the above line - needs to be done separately lines = lines.replace("\n", "\n ") self._log(ERROR, lines) + +def critical(msg, *args, **kwargs): + """ + Log a message with severity 'CRITICAL' on the root logger. + """ + getLogger().critical(msg, *args, **kwargs) + +def fatal(msg, *args, **kwargs): + """ + Don't use this function, use critical() instead. + """ + critical(msg, *args, **kwargs) + +def error(msg, *args, **kwargs): + """ + Log a message with severity 'ERROR' on the root logger. + """ + getLogger().error(msg, *args, **kwargs) + +def warning(msg, *args, **kwargs): + """ + Log a message with severity 'WARNING' on the root logger. + """ + getLogger().warning(msg, *args, **kwargs) + +def warn(msg, *args, **kwargs): + """ + Don't use this function, use warning() instead. + """ + warning(msg, *args, **kwargs) + +def info(msg, *args, **kwargs): + """ + Log a message with severity 'INFO' on the root logger. + """ + getLogger().info(msg, *args, **kwargs) + +def debug(msg, *args, **kwargs): + """ + Log a message with severity 'DEBUG' on the root logger. + """ + getLogger().debug(msg, *args, **kwargs) + +def log(level, msg, *args, **kwargs): + """ + Log 'msg % args' with the integer severity 'level' on the root logger. + """ + getLogger().log(level, msg, *args, **kwargs) From 539f85ddebadc50a24ed360eed9d1360a06ae47d Mon Sep 17 00:00:00 2001 From: Doug Wegscheid Date: Tue, 23 Sep 2025 11:39:16 -0400 Subject: [PATCH 2/2] ruff... --- adafruit_logging.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adafruit_logging.py b/adafruit_logging.py index ac0dc19..0b135aa 100644 --- a/adafruit_logging.py +++ b/adafruit_logging.py @@ -618,48 +618,56 @@ def exception(self, err: Exception) -> None: lines = lines.replace("\n", "\n ") self._log(ERROR, lines) + def critical(msg, *args, **kwargs): """ Log a message with severity 'CRITICAL' on the root logger. """ getLogger().critical(msg, *args, **kwargs) + def fatal(msg, *args, **kwargs): """ Don't use this function, use critical() instead. """ critical(msg, *args, **kwargs) + def error(msg, *args, **kwargs): """ Log a message with severity 'ERROR' on the root logger. """ getLogger().error(msg, *args, **kwargs) + def warning(msg, *args, **kwargs): """ Log a message with severity 'WARNING' on the root logger. """ getLogger().warning(msg, *args, **kwargs) + def warn(msg, *args, **kwargs): """ Don't use this function, use warning() instead. """ warning(msg, *args, **kwargs) + def info(msg, *args, **kwargs): """ Log a message with severity 'INFO' on the root logger. """ getLogger().info(msg, *args, **kwargs) + def debug(msg, *args, **kwargs): """ Log a message with severity 'DEBUG' on the root logger. """ getLogger().debug(msg, *args, **kwargs) + def log(level, msg, *args, **kwargs): """ Log 'msg % args' with the integer severity 'level' on the root logger.