From 6c3b17b35576f15497f1e6008957c2a940c97d76 Mon Sep 17 00:00:00 2001 From: Rajiv Bakulesh Shah Date: Tue, 11 Jan 2022 23:22:05 -0800 Subject: [PATCH] Properly configure logging for the Pottery library (#591) * Properly configure logging for the Pottery library References: 1. https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library 2. https://github.com/elastic/elasticsearch-py/blob/013433e5008277144065ad8e82f66870b203269a/elasticsearch/__init__.py#L43 * Bump version number --- pottery/__init__.py | 2 +- pottery/base.py | 2 ++ pottery/monkey.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pottery/__init__.py b/pottery/__init__.py index 7bc5a2ea..151c1e08 100644 --- a/pottery/__init__.py +++ b/pottery/__init__.py @@ -32,7 +32,7 @@ __title__: Final[str] = 'pottery' -__version__: Final[str] = '2.3.5' +__version__: Final[str] = '2.3.6' __description__: Final[str] = __doc__.split(sep='\n\n', maxsplit=1)[0] __url__: Final[str] = 'https://github.com/brainix/pottery' __author__: Final[str] = 'Rajiv Bakulesh Shah' diff --git a/pottery/base.py b/pottery/base.py index 982b704e..4756dabe 100644 --- a/pottery/base.py +++ b/pottery/base.py @@ -55,6 +55,8 @@ logger: Final[logging.Logger] = logging.getLogger('pottery') +logger.addHandler(logging.NullHandler()) + _default_url: Final[str] = os.environ.get('REDIS_URL', 'redis://localhost:6379/0') _default_redis: Final[Redis] = Redis.from_url(_default_url, socket_timeout=1) diff --git a/pottery/monkey.py b/pottery/monkey.py index 9c8add80..3b7d7e55 100644 --- a/pottery/monkey.py +++ b/pottery/monkey.py @@ -29,6 +29,7 @@ _logger: Final[logging.Logger] = logging.getLogger('pottery') +_logger.addHandler(logging.NullHandler()) # Monkey patch the JSON encoder to be able to JSONify any instance of any class