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

@ -113,8 +113,8 @@ class SyncRestServlet(RestServlet):
logger.debug( logger.debug(
"/sync: user=%r, timeout=%r, since=%r, " "/sync: user=%r, timeout=%r, since=%r, "
" set_presence=%r, filter_id=%r, device_id=%r" "set_presence=%r, filter_id=%r, device_id=%r",
% (user, timeout, since, set_presence, filter_id, device_id) user, timeout, since, set_presence, filter_id, device_id
) )
request_key = (user, timeout, since, filter_id, full_state, 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] pattern = entry[attrib]
value = getattr(url_tuple, attrib) value = getattr(url_tuple, attrib)
logger.debug( logger.debug(
("Matching attrib '%s' with value '%s' against" " pattern '%s'") "Matching attrib '%s' with value '%s' against" " pattern '%s'",
% (attrib, value, pattern) attrib, value, pattern
) )
if value is None: if value is None:
@ -186,7 +186,7 @@ class PreviewUrlResource(DirectServeResource):
media_info = yield self._download_url(url, user) 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"]): if _is_media(media_info["media_type"]):
file_id = media_info["filesystem_id"] file_id = media_info["filesystem_id"]
@ -254,7 +254,7 @@ class PreviewUrlResource(DirectServeResource):
og["og:image:width"] = dims["width"] og["og:image:width"] = dims["width"]
og["og:image:height"] = dims["height"] og["og:image:height"] = dims["height"]
else: 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" % ( og["og:image"] = "mxc://%s/%s" % (
self.server_name, self.server_name,
@ -268,7 +268,7 @@ class PreviewUrlResource(DirectServeResource):
logger.warn("Failed to find any OG data in %s", url) logger.warn("Failed to find any OG data in %s", url)
og = {} 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) jsonog = json.dumps(og)
@ -297,7 +297,7 @@ class PreviewUrlResource(DirectServeResource):
with self.media_storage.store_into_file(file_info) as (f, fname, finish): with self.media_storage.store_into_file(file_info) as (f, fname, finish):
try: 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( length, headers, uri, code = yield self.client.get_file(
url, output_stream=f, max_size=self.max_spider_size url, output_stream=f, max_size=self.max_spider_size
) )