diff --git a/check_patroni/cli.py b/check_patroni/cli.py index 0a30e17..7fc1b8b 100644 --- a/check_patroni/cli.py +++ b/check_patroni/cli.py @@ -33,7 +33,7 @@ from .node import ( from .types import ConnectionInfo, Parameters from .convert import size_to_byte -_log = logging.getLogger("nagiosplugin") +_log = logging.getLogger(__name__) DEFAULT_CFG = "config.ini" @@ -162,6 +162,10 @@ def main( tendpoints += re.split(r"\s*,\s*", e) endpoints = tendpoints + if verbose == 3: + logging.basicConfig(format="%(levelname)s - %(message)s", level=logging.DEBUG) + logging.getLogger("urllib3").setLevel(logging.DEBUG) + ctx.obj = Parameters( ConnectionInfo(endpoints, cert_file, key_file, ca_file), timeout, diff --git a/check_patroni/cluster.py b/check_patroni/cluster.py index 73a9855..27865bc 100644 --- a/check_patroni/cluster.py +++ b/check_patroni/cluster.py @@ -8,7 +8,7 @@ from typing import Iterable, Union from .types import PatroniResource, ConnectionInfo, handle_unknown -_log = logging.getLogger("nagiosplugin") +_log = logging.getLogger(__name__) def replace_chars(text: str) -> str: diff --git a/check_patroni/node.py b/check_patroni/node.py index 8fa840a..2c65f09 100644 --- a/check_patroni/node.py +++ b/check_patroni/node.py @@ -5,7 +5,7 @@ from typing import Iterable from .types import APIError, ConnectionInfo, handle_unknown, PatroniResource -_log = logging.getLogger("nagiosplugin") +_log = logging.getLogger(__name__) class NodeIsPrimary(PatroniResource): diff --git a/check_patroni/types.py b/check_patroni/types.py index 09d7bbe..fa89d31 100644 --- a/check_patroni/types.py +++ b/check_patroni/types.py @@ -3,10 +3,9 @@ import logging import attr import nagiosplugin import requests -import urllib3 from typing import Any, Callable, List, Optional, Tuple, Union -_log = logging.getLogger("nagiosplugin") +_log = logging.getLogger(__name__) class APIError(requests.exceptions.RequestException): @@ -71,7 +70,7 @@ class PatroniResource(nagiosplugin.Resource): ) r = requests.get(f"{endpoint}/{service}", verify=verify, cert=cert) - _log.debug(f"api call status: {r.status_code}") + # The status code is already handled by urllib3 _log.debug(f"api call data: {r.text}") if r.status_code != 200: