Skip to content

Commit

Permalink
Truncate message in logs to 500 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
rebkwok committed Feb 9, 2024
1 parent cf19688 commit 9780229
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ebmbot/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ def notify_slack(
if message_format == "blocks":
msg_kwargs["blocks"] = message_text

# Truncate message text to the first charcters
log_message_text = message_text[:500]
if len(log_message_text) < message_text:
log_message_text += " (truncated)"

logger.info(
"Sending message", channel=channel, message=message_text, thread_ts=thread_ts
"Sending message",
channel=channel,
message=log_message_text,
thread_ts=thread_ts,
)
# If messages are longer than 4000 characters, Slack will split them over
# multiple messages. This breaks code formatting, so if a message with code
Expand Down

0 comments on commit 9780229

Please sign in to comment.