mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
(fix) alerting - show timestamps in alert
This commit is contained in:
parent
44718e59e9
commit
0f51cd0bab
2 changed files with 9 additions and 2 deletions
|
@ -8,7 +8,7 @@ handler.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
# Create a formatter and set it for the handler
|
# Create a formatter and set it for the handler
|
||||||
formatter = logging.Formatter(
|
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",
|
datefmt="%H:%M:%S",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@ class ProxyLogging:
|
||||||
request_info = f"\nRequest Model: {model}\nMessages: {messages}"
|
request_info = f"\nRequest Model: {model}\nMessages: {messages}"
|
||||||
else:
|
else:
|
||||||
request_info = ""
|
request_info = ""
|
||||||
|
|
||||||
if type == "hanging_request":
|
if type == "hanging_request":
|
||||||
# Simulate a long-running operation that could take more than 5 minutes
|
# Simulate a long-running operation that could take more than 5 minutes
|
||||||
await asyncio.sleep(
|
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'.
|
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
|
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:
|
if self.alerting is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue