Delay printf until logging is required.

Using % will cause the string to be generated even if debugging
is off.
This commit is contained in:
Michael Kaye 2019-10-24 18:31:53 +01:00
parent 9eebc1e73b
commit 8f4a808d9d
2 changed files with 9 additions and 9 deletions

View file

@ -112,9 +112,9 @@ class SyncRestServlet(RestServlet):
full_state = parse_boolean(request, "full_state", default=False)
logger.debug(
"/sync: user=%r, timeout=%r, since=%r,"
" set_presence=%r, filter_id=%r, device_id=%r"
% (user, timeout, since, set_presence, filter_id, device_id)
"/sync: user=%r, timeout=%r, since=%r, "
"set_presence=%r, filter_id=%r, device_id=%r",
user, timeout, since, set_presence, filter_id, device_id
)
request_key = (user, timeout, since, filter_id, full_state, device_id)

View file

@ -117,8 +117,8 @@ class PreviewUrlResource(DirectServeResource):
pattern = entry[attrib]
value = getattr(url_tuple, attrib)
logger.debug(
("Matching attrib '%s' with value '%s' against" " pattern '%s'")
% (attrib, value, pattern)
"Matching attrib '%s' with value '%s' against" " pattern '%s'",
attrib, value, pattern
)
if value is None:
@ -186,7 +186,7 @@ class PreviewUrlResource(DirectServeResource):
media_info = yield self._download_url(url, user)
logger.debug("got media_info of '%s'" % media_info)
logger.debug("got media_info of '%s'", media_info)
if _is_media(media_info["media_type"]):
file_id = media_info["filesystem_id"]
@ -254,7 +254,7 @@ class PreviewUrlResource(DirectServeResource):
og["og:image:width"] = dims["width"]
og["og:image:height"] = dims["height"]
else:
logger.warn("Couldn't get dims for %s" % og["og:image"])
logger.warn("Couldn't get dims for %s", og["og:image"])
og["og:image"] = "mxc://%s/%s" % (
self.server_name,
@ -268,7 +268,7 @@ class PreviewUrlResource(DirectServeResource):
logger.warn("Failed to find any OG data in %s", url)
og = {}
logger.debug("Calculated OG for %s as %s" % (url, og))
logger.debug("Calculated OG for %s as %s", url, og)
jsonog = json.dumps(og)
@ -297,7 +297,7 @@ class PreviewUrlResource(DirectServeResource):
with self.media_storage.store_into_file(file_info) as (f, fname, finish):
try:
logger.debug("Trying to get url '%s'" % url)
logger.debug("Trying to get url '%s'", url)
length, headers, uri, code = yield self.client.get_file(
url, output_stream=f, max_size=self.max_spider_size
)