Cosmetics: Don't use % for logging

This commit is contained in:
Unrud 2016-08-10 23:42:48 +02:00
parent 9192a7751b
commit e2b87d145f
4 changed files with 25 additions and 25 deletions

View File

@ -200,22 +200,22 @@ class Application:
path = item.collection.path
if self.authorized(user, path, "r"):
self.logger.debug(
"%s has read access to collection %s" %
(user or "Anonymous", path or "/"))
"%s has read access to collection %s",
user or "Anonymous", path or "/")
read_allowed_items.append(item)
else:
self.logger.debug(
"%s has NO read access to collection %s" %
(user or "Anonymous", path or "/"))
"%s has NO read access to collection %s",
user or "Anonymous", path or "/")
if self.authorized(user, path, "w"):
self.logger.debug(
"%s has write access to collection %s" %
(user or "Anonymous", path or "/"))
"%s has write access to collection %s",
user or "Anonymous", path or "/")
write_allowed_items.append(item)
else:
self.logger.debug(
"%s has NO write access to collection %s" %
(user or "Anonymous", path or "/"))
"%s has NO write access to collection %s",
user or "Anonymous", path or "/")
return read_allowed_items, write_allowed_items
def __call__(self, environ, start_response):
@ -225,16 +225,16 @@ class Application:
# Start response
status = "%i %s" % (
status, client.responses.get(status, "Unknown"))
self.logger.debug("Answer status: %s" % status)
self.logger.debug("Answer status: %s", status)
start_response(status, list(headers.items()))
# Return response content
return [answer] if answer else []
self.logger.debug("\n") # Add empty lines between requests in debug
self.logger.info("%s request at %s received" % (
environ["REQUEST_METHOD"], environ["PATH_INFO"]))
self.logger.info("%s request at %s received",
environ["REQUEST_METHOD"], environ["PATH_INFO"])
headers = pprint.pformat(self.headers_log(environ))
self.logger.debug("Request headers:\n%s" % headers)
self.logger.debug("Request headers:\n%s", headers)
# Strip base_prefix from request URI
base_prefix = self.configuration.get("server", "base_prefix")
@ -323,7 +323,7 @@ class Application:
# Set content length
if answer:
self.logger.debug("Response content:\n%s" % answer)
self.logger.debug("Response content:\n%s", answer)
answer = answer.encode(self.encoding)
accept_encoding = [
encoding.strip() for encoding in
@ -381,7 +381,7 @@ class Application:
if content_length > 0:
content = self.decode(
environ["wsgi.input"].read(content_length), environ)
self.logger.debug("Request content:\n%s" % content.strip())
self.logger.debug("Request content:\n%s", content.strip())
else:
content = None
return content

View File

@ -150,7 +150,7 @@ def serve(configuration, logger):
logger.info("Starting Radicale")
logger.debug(
"Base URL prefix: %s" % configuration.get("server", "base_prefix"))
"Base URL prefix: %s", configuration.get("server", "base_prefix"))
# Create collection servers
servers = {}
@ -187,8 +187,8 @@ def serve(configuration, logger):
server = make_server(
address, port, application, server_class, RequestHandler)
servers[server.socket] = server
logger.debug("Listening to %s port %s" % (
server.server_name, server.server_port))
logger.debug("Listening to %s port %s",
server.server_name, server.server_port)
if configuration.getboolean("server", "ssl"):
logger.debug("Using SSL")

View File

@ -63,7 +63,7 @@ from importlib import import_module
def load(configuration, logger):
"""Load the authentication manager chosen in configuration."""
auth_type = configuration.get("auth", "type")
logger.debug("Authentication type is %s" % auth_type)
logger.debug("Authentication type is %s", auth_type)
if auth_type == "None":
return lambda user, password: True
elif auth_type == "htpasswd":

View File

@ -119,27 +119,27 @@ class Rights(BaseRights):
regex = ConfigParser(
{"login": user_escaped, "path": sane_path_escaped})
if self.rights_type in DEFINED_RIGHTS:
self.logger.debug("Rights type '%s'" % self.rights_type)
self.logger.debug("Rights type '%s'", self.rights_type)
regex.readfp(StringIO(DEFINED_RIGHTS[self.rights_type]))
else:
self.logger.debug("Reading rights from file '%s'" % self.filename)
self.logger.debug("Reading rights from file '%s'", self.filename)
if not regex.read(self.filename):
self.logger.error(
"File '%s' not found for rights" % self.filename)
"File '%s' not found for rights", self.filename)
return False
for section in regex.sections():
re_user = regex.get(section, "user")
re_collection = regex.get(section, "collection")
self.logger.debug(
"Test if '%s:%s' matches against '%s:%s' from section '%s'" % (
user, sane_path, re_user, re_collection, section))
"Test if '%s:%s' matches against '%s:%s' from section '%s'",
user, sane_path, re_user, re_collection, section)
user_match = re.fullmatch(re_user, user)
if user_match:
re_collection = re_collection.format(*user_match.groups())
if re.fullmatch(re_collection, sane_path):
self.logger.debug("Section '%s' matches" % section)
self.logger.debug("Section '%s' matches", section)
return permission in regex.get(section, "permission")
else:
self.logger.debug("Section '%s' does not match" % section)
self.logger.debug("Section '%s' does not match", section)
return False