From 6cd07a45a942b5aa14d2816f0c68097afa84d369 Mon Sep 17 00:00:00 2001 From: Julien Rische Date: Mon, 18 Nov 2024 10:01:16 +0100 Subject: [PATCH] Use dedicated "kdcproxy" logger Signed-off-by: Julien Rische --- kdcproxy/__init__.py | 6 ++++-- kdcproxy/config/__init__.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kdcproxy/__init__.py b/kdcproxy/__init__.py index 32aa3e1..765cba1 100644 --- a/kdcproxy/__init__.py +++ b/kdcproxy/__init__.py @@ -38,6 +38,8 @@ import httplib import urlparse +logger = logging.getLogger('kdcproxy') + class HTTPException(Exception): @@ -105,7 +107,7 @@ def __await_reply(self, pr, rsocks, wsocks, timeout): sock.sendall(pr.request) extra = 10 # New connections get 10 extra seconds except Exception as e: - logging.warning("Connection broken while writing (%s)", e) + logger.warning("Connection broken while writing (%s)", e) reactivations[sock] = (react_n + 1, time.time() + 2.0**(react_n+1) / 10) continue @@ -118,7 +120,7 @@ def __await_reply(self, pr, rsocks, wsocks, timeout): try: reply = self.__handle_recv(sock, read_buffers) except Exception as e: - logging.warning("Connection broken while reading (%s)", e) + logger.warning("Connection broken while reading (%s)", e) if self.sock_type(sock) == socket.SOCK_STREAM: # Remove broken TCP socket from readers rsocks.remove(sock) diff --git a/kdcproxy/config/__init__.py b/kdcproxy/config/__init__.py index a1435b7..2348d9b 100644 --- a/kdcproxy/config/__init__.py +++ b/kdcproxy/config/__init__.py @@ -32,6 +32,8 @@ import dns.rdatatype import dns.resolver +logger = logging.getLogger('kdcproxy') + class IResolver(object): @@ -60,14 +62,14 @@ def __init__(self, filenames=None): try: self.__cp.read(filenames) except configparser.Error: - logging.error("Unable to read config file(s): %s", filenames) + logger.error("Unable to read config file(s): %s", filenames) try: mod = self.__cp.get(self.GLOBAL, "configs") try: importlib.import_module("kdcproxy.config." + mod) except ImportError as e: - logging.log(logging.ERROR, "Error reading config: %s" % e) + logger.log(logging.ERROR, "Error reading config: %s" % e) except configparser.Error: pass