From 93b61ee2ae6ed062449022c7a184adc4f7581ade Mon Sep 17 00:00:00 2001 From: Paddy Roddy Date: Fri, 15 Sep 2023 15:24:35 +0100 Subject: [PATCH 1/2] DEV: Improve logging --- heracles/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/heracles/__init__.py b/heracles/__init__.py index 08a3b7d..6d979c4 100644 --- a/heracles/__init__.py +++ b/heracles/__init__.py @@ -17,7 +17,21 @@ # You should have received a copy of the GNU Lesser General Public # License along with Heracles. If not, see . +import logging + try: from ._version import __version__, __version_tuple__ # noqa: F401 except ModuleNotFoundError: pass + +_logger = logging.getLogger(__name__) + +_formatter = logging.Formatter( + "%(levelname)s [%(asctime)s] sleplet: %(message)s", + datefmt="%Y-%m-%d %H:%M:%S", +) +_console_handler = logging.StreamHandler() +_console_handler.setFormatter(_formatter) +_logger.addHandler(_console_handler) +_logger.setLevel("INFO") +_logger.propagate = False From ad0934709557580fa54e71dd7df74c501818d1a2 Mon Sep 17 00:00:00 2001 From: Paddy Roddy Date: Fri, 15 Sep 2023 15:26:30 +0100 Subject: [PATCH 2/2] Fix package name --- heracles/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heracles/__init__.py b/heracles/__init__.py index 6d979c4..95eb4f5 100644 --- a/heracles/__init__.py +++ b/heracles/__init__.py @@ -27,7 +27,7 @@ _logger = logging.getLogger(__name__) _formatter = logging.Formatter( - "%(levelname)s [%(asctime)s] sleplet: %(message)s", + "%(levelname)s [%(asctime)s] heracles: %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) _console_handler = logging.StreamHandler()