Skip to content

Commit

Permalink
Use dedicated "kdcproxy" logger
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Rische <[email protected]>
  • Loading branch information
jrisc committed Nov 18, 2024
1 parent 66278c8 commit 4284384
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions kdcproxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
import httplib
import urlparse

logging.basicConfig()
logger = logging.getLogger('kdcproxy')


class HTTPException(Exception):

Expand Down Expand Up @@ -105,7 +108,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
Expand All @@ -118,7 +121,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)
Expand Down
7 changes: 5 additions & 2 deletions kdcproxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import dns.rdatatype
import dns.resolver

logging.basicConfig()
logger = logging.getLogger('kdcproxy')


class IResolver(object):

Expand Down Expand Up @@ -60,14 +63,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

Expand Down

0 comments on commit 4284384

Please sign in to comment.