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

View File

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

View File

@ -63,7 +63,7 @@ from importlib import import_module
def load(configuration, logger): def load(configuration, logger):
"""Load the authentication manager chosen in configuration.""" """Load the authentication manager chosen in configuration."""
auth_type = configuration.get("auth", "type") 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": if auth_type == "None":
return lambda user, password: True return lambda user, password: True
elif auth_type == "htpasswd": elif auth_type == "htpasswd":

View File

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