fix(crawler): replace print statements with logger for better logging

Updated the crawler to use the logger for outputting article information and toot notifications, enhancing the logging mechanism for improved monitoring and debugging.
This commit is contained in:
Ching L 2025-04-07 11:33:28 +08:00
parent 15addaba24
commit da1969b103

View File

@ -91,7 +91,7 @@ def crawler():
# save the article info to redis # save the article info to redis
if save_to_redis(article): if save_to_redis(article):
print(article) logger.info(article)
def toot(): def toot():
# get all the keys in redis # get all the keys in redis
@ -117,6 +117,7 @@ def toot():
url=article['url']) url=article['url'])
mastodon_client.status_post(toot_content, media_ids=[media['id']]) mastodon_client.status_post(toot_content, media_ids=[media['id']])
logger.info('Toot %s' % article['title'])
# add the article['id'] to the set # add the article['id'] to the set
redis_db.sadd('send-chh-article-id', article['article_id']) redis_db.sadd('send-chh-article-id', article['article_id'])