diff options
author | John L. Villalovos <john@sodarock.com> | 2022-10-03 21:29:54 -0700 |
---|---|---|
committer | Nejc Habjan <nejc.habjan@siemens.com> | 2023-03-12 20:23:40 +0100 |
commit | b476afe9928c6e844b86b56f9316ae1a1fe254f2 (patch) | |
tree | 8aa4e2743dacd661365d04bdfedf8477626d6fce /tests/unit/test__logging.py | |
parent | 7a8a86278543a1419d07dd022196e4cb3db12d31 (diff) | |
download | gitlab-jlvillal/logging.tar.gz |
chore: add bare-minimum logging supportjlvillal/logging
Follow the Python documentation guidelines for "Configuring Logging
for a Library" [1]
Which is basically adding these two lines:
import logging
logging.getLogger(__name__).addHandler(logging.NullHandler())
Setup a very basic usage of logging in `gitlab/client.py`
By using the NullHandler it means that by default any log messages
output will not be displayed. It is up to the client application to do
a `logging.basicConfig()` call to get log messages to display.
[1] https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
Related: #2080
Diffstat (limited to 'tests/unit/test__logging.py')
-rw-r--r-- | tests/unit/test__logging.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/test__logging.py b/tests/unit/test__logging.py new file mode 100644 index 0000000..9248f86 --- /dev/null +++ b/tests/unit/test__logging.py @@ -0,0 +1,24 @@ +import logging + +import pytest + +from gitlab import _logging + + +@pytest.fixture +def LOG(): + return logging.getLogger(_logging._module_root_logger_name) + + +def test_module_root_logger_name(): + assert _logging._module_root_logger_name == "gitlab" + + +def test_module_name(LOG): + assert LOG.name == "gitlab" + + +def test_logger_null_handler(LOG): + assert len(LOG.handlers) == 1 + handler = LOG.handlers[0] + assert isinstance(handler, logging.NullHandler) |