(fix) alerting - show timestamps in alert

This commit is contained in:
ishaan-jaff 2024-01-24 15:25:40 -08:00
parent 44718e59e9
commit 0f51cd0bab
2 changed files with 9 additions and 2 deletions

View file

@ -8,7 +8,7 @@ handler.setLevel(logging.DEBUG)
# Create a formatter and set it for the handler
formatter = logging.Formatter(
"\033[92m%(asctime)s - %(name)s - %(levelname)s\033[0m: %(message)s",
"\033[92m%(asctime)s - %(name)s:%(levelname)s\033[0m: %(message)s",
datefmt="%H:%M:%S",
)

View file

@ -152,6 +152,7 @@ class ProxyLogging:
request_info = f"\nRequest Model: {model}\nMessages: {messages}"
else:
request_info = ""
if type == "hanging_request":
# Simulate a long-running operation that could take more than 5 minutes
await asyncio.sleep(
@ -193,7 +194,13 @@ class ProxyLogging:
level: str - Low|Medium|High - if calls might fail (Medium) or are failing (High); Currently, no alerts would be 'Low'.
message: str - what is the alert about
"""
formatted_message = f"Level: {level}\n\nMessage: {message}"
from datetime import datetime
# Get the current timestamp
current_time = datetime.now().strftime("%H:%M:%S")
formatted_message = (
f"Level: {level}\nTimestamp: {current_time}\n\nMessage: {message}"
)
if self.alerting is None:
return