Skip to content

Commit 6a00724

Browse files
use exc_info in logging
1 parent bd45046 commit 6a00724

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/audiotools/speech.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def transcribe(self, chunk):
4747
text = data["text"]
4848

4949
except requests.exceptions.RequestException as e:
50-
logger.error("Could not transcribe chunk: %s", traceback.format_exc())
50+
logger.error("Could not transcribe chunk", exc_info=True)
5151

5252
return text
5353

src/database/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
3838
logger.error("exc_type: {}".format(exc_type))
3939
logger.error("exc_value: {}".format(exc_value))
4040
logger.error("exc_traceback: {}".format(exc_traceback))
41-
logger.error(traceback.format_exc())
41+
logger.error("Caught exception", exc_info=True)
4242

4343
return True
4444

src/transcriberbot/blueprints/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ async def __post():
214214
await asyncio.sleep(0.1)
215215
except Exception as e:
216216
logging.error(
217-
"Exception sending broadcast to %d: (%s) %s",
218-
chat['chat_id'], e, traceback.format_exc()
217+
"Exception sending broadcast to %d: (%s)",
218+
chat['chat_id'], e, exc_info=True
219219
)
220220

221221
await context.bot.send_message(

src/transcriberbot/blueprints/photos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def process_media_photo(update: Update, context: ContextTypes.DEFAULT_TYPE
6969
)
7070

7171
except Exception as e:
72-
logging.error("Exception handling photo from %d: %s", chat_id, traceback.format_exc())
72+
logging.error("Exception handling photo from %d", chat_id, exc_info=True)
7373

7474
finally:
7575
os.remove(file_path)

src/transcriberbot/blueprints/voice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def process_media_voice(update: Update, context: ContextTypes.DEFAULT_TYPE
114114
try:
115115
await transcribe_audio_file(update, context, file_path)
116116
except Exception:
117-
logger.error("Exception handling %s from %d: %s", name, chat_id, traceback.format_exc())
117+
logger.error("Exception handling %s from %d", name, chat_id, exc_info=True)
118118
finally:
119119
os.remove(file_path)
120120

0 commit comments

Comments
 (0)