Skip to content

Commit

Permalink
Format everything passed to logging
Browse files Browse the repository at this point in the history
  • Loading branch information
zstyblik committed Jun 7, 2024
1 parent 7c4d214 commit f25f3c4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions gh2slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def format_message(
"Failed to encode title as UTF-8: %s",
repr(cache_item.get("title", None)),
)
logger.error(traceback.format_exc())
logger.error("%s", traceback.format_exc())
title = "Unknown title due to UTF-8 exception, {:s}#{:d}".format(
section, cache_item["number"]
)
Expand Down Expand Up @@ -194,14 +194,14 @@ def main():
args.slack_channel,
)
except Exception:
logger.error(traceback.format_exc())
logger.error("%s", traceback.format_exc())
cache.items.pop(html_url)
finally:
time.sleep(args.sleep)

rss2irc.write_cache(cache, args.cache)
except Exception:
logger.debug(traceback.format_exc())
logger.debug("%s", traceback.format_exc())
# TODO(zstyblik):
# 1. touch error file
# 2. send error message to the channel
Expand Down Expand Up @@ -354,7 +354,7 @@ def scrub_items(logger: logging.Logger, cache: rss2irc.CachedData) -> None:
try:
expiration = int(cache.items[key]["expiration"])
except (KeyError, ValueError):
logger.error(traceback.format_exc())
logger.error("%s", traceback.format_exc())
logger.error(
"Invalid cache entry will be removed: '%s'", cache.items[key]
)
Expand Down
2 changes: 1 addition & 1 deletion git_commits2slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def main():
args.slack_channel,
)
except Exception:
logger.debug(traceback.format_exc())
logger.debug("%s", traceback.format_exc())
# TODO(zstyblik):
# 1. touch error file
# 2. send error message to the channel
Expand Down
6 changes: 3 additions & 3 deletions phpbb2slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_authors_from_file(logger: logging.Logger, fname: str) -> List[str]:
if line.decode("utf-8").strip() != ""
]
except Exception:
logger.error(traceback.format_exc())
logger.error("%s", traceback.format_exc())
authors = []

return authors
Expand Down Expand Up @@ -130,7 +130,7 @@ def main():
cache.scrub_data_sources()
rss2irc.write_cache(cache, args.cache)
except Exception:
logger.debug(traceback.format_exc())
logger.debug("%s", traceback.format_exc())
# TODO(zstyblik):
# 1. touch error file
# 2. send error message to the channel
Expand Down Expand Up @@ -299,7 +299,7 @@ def scrub_items(logger: logging.Logger, cache: rss2irc.CachedData) -> None:
try:
expiration = int(cache.items[key]["expiration"])
except (KeyError, ValueError):
logger.error(traceback.format_exc())
logger.error("%s", traceback.format_exc())
logger.error(
"Invalid cache entry will be removed: '%s'", cache.items[key]
)
Expand Down
8 changes: 4 additions & 4 deletions rss2irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def main():
write_cache(cache, args.cache)
# TODO(zstyblik): remove error file
except Exception:
logger.debug(traceback.format_exc())
logger.debug("%s", traceback.format_exc())
# TODO(zstyblik):
# 1. touch error file
# 2. send error message to the channel
Expand Down Expand Up @@ -318,7 +318,7 @@ def read_cache(logger: logging.Logger, cache_file: str) -> CachedData:
traceback.format_exc(),
)

logger.debug(cache)
logger.debug("%s", cache)
return cache


Expand All @@ -334,7 +334,7 @@ def scrub_items(logger: logging.Logger, cache: CachedData) -> None:
try:
expiration = int(cache.items[key])
except ValueError:
logger.error(traceback.format_exc())
logger.error("%s", traceback.format_exc())
logger.error(
"Invalid cache entry will be removed: '%s'", cache.items[key]
)
Expand Down Expand Up @@ -381,7 +381,7 @@ def write_data(
write_message(logger, fhandle, message)
time.sleep(sleep)
except ValueError:
logger.debug(traceback.format_exc())
logger.debug("%s", traceback.format_exc())
logger.debug("Failed to write %s, %s", url, data[url])
data.pop(url)

Expand Down
4 changes: 2 additions & 2 deletions rss2slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def main():
rss2irc.write_cache(cache, args.cache)
# TODO(zstyblik): remove error file
except Exception:
logger.debug(traceback.format_exc())
logger.debug("%s", traceback.format_exc())
# TODO(zstyblik):
# 1. touch error file
# 2. send error message to the channel
Expand Down Expand Up @@ -248,7 +248,7 @@ def post_to_slack(
if not rsp or rsp["ok"] is False:
raise ValueError("Slack response is not OK.")
except ValueError:
logger.debug(traceback.format_exc())
logger.debug("%s", traceback.format_exc())
raise


Expand Down

0 comments on commit f25f3c4

Please sign in to comment.