logging: update logging levels and added new messages

This commit is contained in:
A.M. Rowsell 2026-04-24 10:51:59 -04:00
commit 63300e6012
Signed by: amr
GPG key ID: E0879EDBDB0CA7B1

View file

@ -116,16 +116,15 @@ class Discorss:
"Feed %s doesn't supply a published time, using updated time instead",
hook["name"],
)
self.logger.debug("Feed url is %s", latest_post["url"])
# Hash the url of the latest post and use that to determine if it's been posted
# Yes, SHA3-512 is totally unnecessary for this purpose, but I love SHA3
self.logger.debug("About to hash %s ...", latest_post["url"])
self.logger.debug("About to hash %s ...", latest_post["link"])
try:
new_hash = hashlib.sha3_512(
bytes(latest_post["url"], "utf-8") # Removed time from hash
bytes(latest_post["link"], "utf-8") # Removed time from hash
).hexdigest()
except TypeError:
self.logger.error("URL of %s isn't hashing correctly", hook["name"])
self.logger.error("URL %s isn't hashing correctly", hook["link"])
return None
if new_hash in self._get_hash_history(hook):
@ -173,7 +172,7 @@ class Discorss:
if not self.DRY_RUN:
response = await self._post_webhook(hook, webhook_string, custom_header)
else:
self.logger.debug(
self.logger.info(
"Dry run, not actually posting to webhook, faking return code 200"
)
response = SimpleNamespace(status_code=200)
@ -200,14 +199,14 @@ class Discorss:
for i, result in enumerate(results):
hook = self.app_config["feeds"][i]
if isinstance(result, asyncio.TimeoutError):
self.logger.error(
self.logger.critical(
"Timed out processing feed %s after %d seconds",
hook["name"],
self.FEED_TIMEOUT_SECONDS,
)
continue
if isinstance(result, requests.RequestException):
self.logger.error(
self.logger.critical(
"Network error while processing feed %s: %s",
hook["name"],
result,
@ -223,7 +222,7 @@ class Discorss:
if result is None:
continue
if "lasthash" not in hook:
self.logger.info(
self.logger.debug(
"Feed %s has no existing hash, likely a new feed!", hook["name"]
)
hash_history = self._get_hash_history(hook)
@ -303,10 +302,11 @@ class Discorss:
logging.basicConfig(
filename=self.log_file_path,
encoding="utf-8",
level=logging.DEBUG,
level=logging.INFO,
datefmt="%m/%d/%Y %H:%M:%S",
format="%(asctime)s -> %(levelname)s: %(message)s",
format="%(asctime)s [%(threadName)s] -> %(levelname)s: %(message)s",
)
self.logger.info("========= Started discorss.py ==========")
return
def process(self):
@ -324,7 +324,7 @@ class Discorss:
self.app_config["lastupdate"] = self.now
with open(self.config_file_path, "w") as config_file:
json.dump(self.app_config, config_file, indent=4)
self.logger.info("========= Ended discord.py =========")
return