add more debug data

This commit is contained in:
Antonio J. Delgado 2025-02-17 15:28:08 +02:00
parent 43b426212c
commit ce95bbe185

View file

@ -50,6 +50,7 @@ class MastodonEmailBridge:
'.mastodon_email_bridge_sent_items.db' '.mastodon_email_bridge_sent_items.db'
) )
self._init_log() self._init_log()
self.last_translation_response = None
self._get_sent_posts() self._get_sent_posts()
if 'templates_folder' in self.config: if 'templates_folder' in self.config:
templates_folder=self.config['templates_folder'] templates_folder=self.config['templates_folder']
@ -284,6 +285,7 @@ class MastodonEmailBridge:
data[field], data[field],
source_language=source_language source_language=source_language
) )
new_data[f"translated_{field}_response"] = self.last_translation_response
self._log.debug( self._log.debug(
"Total of %s fields translated", "Total of %s fields translated",
counter counter
@ -307,7 +309,8 @@ class MastodonEmailBridge:
data=data, data=data,
) )
try: try:
translation = response.json()['translatedText'] self.last_translation_response = response.json()
translation = self.last_translation_response['translatedText']
except Exception as error: except Exception as error:
self._log.error( self._log.error(
"Error translating '%s' from '%s' to '%s'. %s. Response content: %s", "Error translating '%s' from '%s' to '%s'. %s. Response content: %s",