Change logging
We now use our own logger. When debug is set (-vvv), we also display urllib3's debug info.
This commit is contained in:
parent
7256c1894a
commit
2443505ad6
|
@ -33,7 +33,7 @@ from .node import (
|
||||||
from .types import ConnectionInfo, Parameters
|
from .types import ConnectionInfo, Parameters
|
||||||
from .convert import size_to_byte
|
from .convert import size_to_byte
|
||||||
|
|
||||||
_log = logging.getLogger("nagiosplugin")
|
_log = logging.getLogger(__name__)
|
||||||
DEFAULT_CFG = "config.ini"
|
DEFAULT_CFG = "config.ini"
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,6 +162,10 @@ def main(
|
||||||
tendpoints += re.split(r"\s*,\s*", e)
|
tendpoints += re.split(r"\s*,\s*", e)
|
||||||
endpoints = tendpoints
|
endpoints = tendpoints
|
||||||
|
|
||||||
|
if verbose == 3:
|
||||||
|
logging.basicConfig(format="%(levelname)s - %(message)s", level=logging.DEBUG)
|
||||||
|
logging.getLogger("urllib3").setLevel(logging.DEBUG)
|
||||||
|
|
||||||
ctx.obj = Parameters(
|
ctx.obj = Parameters(
|
||||||
ConnectionInfo(endpoints, cert_file, key_file, ca_file),
|
ConnectionInfo(endpoints, cert_file, key_file, ca_file),
|
||||||
timeout,
|
timeout,
|
||||||
|
|
|
@ -8,7 +8,7 @@ from typing import Iterable, Union
|
||||||
|
|
||||||
from .types import PatroniResource, ConnectionInfo, handle_unknown
|
from .types import PatroniResource, ConnectionInfo, handle_unknown
|
||||||
|
|
||||||
_log = logging.getLogger("nagiosplugin")
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def replace_chars(text: str) -> str:
|
def replace_chars(text: str) -> str:
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Iterable
|
||||||
|
|
||||||
from .types import APIError, ConnectionInfo, handle_unknown, PatroniResource
|
from .types import APIError, ConnectionInfo, handle_unknown, PatroniResource
|
||||||
|
|
||||||
_log = logging.getLogger("nagiosplugin")
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class NodeIsPrimary(PatroniResource):
|
class NodeIsPrimary(PatroniResource):
|
||||||
|
|
|
@ -3,10 +3,9 @@ import logging
|
||||||
import attr
|
import attr
|
||||||
import nagiosplugin
|
import nagiosplugin
|
||||||
import requests
|
import requests
|
||||||
import urllib3
|
|
||||||
from typing import Any, Callable, List, Optional, Tuple, Union
|
from typing import Any, Callable, List, Optional, Tuple, Union
|
||||||
|
|
||||||
_log = logging.getLogger("nagiosplugin")
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class APIError(requests.exceptions.RequestException):
|
class APIError(requests.exceptions.RequestException):
|
||||||
|
@ -71,7 +70,7 @@ class PatroniResource(nagiosplugin.Resource):
|
||||||
)
|
)
|
||||||
|
|
||||||
r = requests.get(f"{endpoint}/{service}", verify=verify, cert=cert)
|
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}")
|
_log.debug(f"api call data: {r.text}")
|
||||||
|
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
|
|
Loading…
Reference in a new issue