Skip to content

Commit

Permalink
Prefix all logging messages with "kdcproxy:"
Browse files Browse the repository at this point in the history
When running kdcproxy in mod_wsgi, it is unclear from which
component error messages come from. For example:

mod_wsgi.c(): [client WARNING:root:Connection broken while writing (...)

Prefixing all logging messages with "kdcproxy:" solves this.

Signed-off-by: François Cami <[email protected]>
  • Loading branch information
fcami committed Mar 22, 2024
1 parent 0148b1c commit 54ccbb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions kdcproxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ 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)
logging.warning(
"kdcproxy: Connection broken while writing (%s)", e)
continue
rsocks.append(sock)
wsocks.remove(sock)
Expand All @@ -110,7 +111,8 @@ 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)
logging.warning(
"kdcproxy: 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
8 changes: 5 additions & 3 deletions kdcproxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ def __init__(self, filenames=None):
try:
self.__cp.read(filenames)
except configparser.Error:
logging.error("Unable to read config file(s): %s", filenames)
logging.error("kdcproxy: 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)
logging.log(logging.ERROR,
"kdcproxy: Error reading config: %s" % e)
except configparser.Error:
pass

Expand Down Expand Up @@ -134,7 +136,7 @@ def __init__(self):
except Exception as e:
fmt = (allsub[i], repr(e))
logging.log(logging.WARNING,
"Error instantiating %s due to %s" % fmt)
"kdcproxy: Error instantiating %s due to %s" % fmt)
assert self.__resolvers

# See if we should use DNS
Expand Down

0 comments on commit 54ccbb8

Please sign in to comment.