Improve logging

This commit is contained in:
jeancf 2023-07-18 16:27:00 +02:00
parent 5d36cd2f7e
commit dba9e7d3ab

View File

@ -1162,7 +1162,7 @@ def main(argv):
logging.info('%d toots not posted due to configured cap', len(tweets) - TOML['options']['toot_cap'])
break
logging.debug('Uploading Tweet %s', tweet["tweet_id"])
logging.debug('Uploading Tweet %s', tweet['tweet_id'])
media_ids = []
@ -1222,7 +1222,8 @@ def main(argv):
_, _, _, exception_message = e.args
if 'Text character limit' in exception_message:
# ERROR (('Mastodon API returned error', 422, 'Unprocessable Entity', 'Validation failed: Text character limit of 500 exceeded'))
logging.error('Toot text too long: %s characters. Skipping.', str(len(tweet['tweet_text'])))
logging.error('Toot text too long: %s characters', str(len(tweet['tweet_text'])))
logging.error('posting ' + tweet['tweet_id'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
continue
elif 'Try again in a moment' in exception_message:
# ERROR ('Mastodon API returned error', 422, 'Unprocessable Entity', 'Cannot attach files that have not finished processing. Try again in a moment!')
@ -1233,13 +1234,13 @@ def main(argv):
try:
toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids)
except MastodonError as me:
logging.error('posting ' + tweet['tweet_text'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
logging.error('posting ' + tweet['tweet_id'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
logging.error(me)
else:
logging.warning("Retry successful")
except MastodonError as me:
logging.error('posting ' + tweet['tweet_text'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
logging.error('posting ' + tweet['tweet_id'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
logging.error(me)
else: