format
This commit is contained in:
parent
c933290886
commit
9df34662cc
1 changed files with 49 additions and 40 deletions
|
|
@ -27,11 +27,11 @@ def configure_external_library_logging():
|
||||||
litellm.set_verbose = False
|
litellm.set_verbose = False
|
||||||
|
|
||||||
# Set additional LiteLLM configuration
|
# Set additional LiteLLM configuration
|
||||||
if hasattr(litellm, 'suppress_debug_info'):
|
if hasattr(litellm, "suppress_debug_info"):
|
||||||
litellm.suppress_debug_info = True
|
litellm.suppress_debug_info = True
|
||||||
if hasattr(litellm, 'turn_off_message'):
|
if hasattr(litellm, "turn_off_message"):
|
||||||
litellm.turn_off_message = True
|
litellm.turn_off_message = True
|
||||||
if hasattr(litellm, '_turn_on_debug'):
|
if hasattr(litellm, "_turn_on_debug"):
|
||||||
litellm._turn_on_debug = False
|
litellm._turn_on_debug = False
|
||||||
|
|
||||||
# Comprehensive logger suppression
|
# Comprehensive logger suppression
|
||||||
|
|
@ -45,7 +45,7 @@ def configure_external_library_logging():
|
||||||
"LiteLLM", # Capital case variant
|
"LiteLLM", # Capital case variant
|
||||||
"LiteLLM.core",
|
"LiteLLM.core",
|
||||||
"LiteLLM.logging_worker",
|
"LiteLLM.logging_worker",
|
||||||
"litellm.logging_worker"
|
"litellm.logging_worker",
|
||||||
]
|
]
|
||||||
|
|
||||||
for logger_name in loggers_to_suppress:
|
for logger_name in loggers_to_suppress:
|
||||||
|
|
@ -279,30 +279,36 @@ def setup_logging(log_level=None, name=None):
|
||||||
|
|
||||||
def filter(self, record):
|
def filter(self, record):
|
||||||
# Check if this is a LiteLLM-related logger
|
# Check if this is a LiteLLM-related logger
|
||||||
if hasattr(record, 'name') and 'litellm' in record.name.lower():
|
if hasattr(record, "name") and "litellm" in record.name.lower():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Check message content for cancellation errors
|
# Check message content for cancellation errors
|
||||||
if hasattr(record, 'msg') and record.msg:
|
if hasattr(record, "msg") and record.msg:
|
||||||
msg_str = str(record.msg).lower()
|
msg_str = str(record.msg).lower()
|
||||||
if any(keyword in msg_str for keyword in [
|
if any(
|
||||||
'loggingworker cancelled',
|
keyword in msg_str
|
||||||
'logging_worker.py',
|
for keyword in [
|
||||||
'cancellederror',
|
"loggingworker cancelled",
|
||||||
'litellm:error'
|
"logging_worker.py",
|
||||||
]):
|
"cancellederror",
|
||||||
|
"litellm:error",
|
||||||
|
]
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Check formatted message
|
# Check formatted message
|
||||||
try:
|
try:
|
||||||
if hasattr(record, 'getMessage'):
|
if hasattr(record, "getMessage"):
|
||||||
formatted_msg = record.getMessage().lower()
|
formatted_msg = record.getMessage().lower()
|
||||||
if any(keyword in formatted_msg for keyword in [
|
if any(
|
||||||
'loggingworker cancelled',
|
keyword in formatted_msg
|
||||||
'logging_worker.py',
|
for keyword in [
|
||||||
'cancellederror',
|
"loggingworker cancelled",
|
||||||
'litellm:error'
|
"logging_worker.py",
|
||||||
]):
|
"cancellederror",
|
||||||
|
"litellm:error",
|
||||||
|
]
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
@ -312,20 +318,23 @@ def setup_logging(log_level=None, name=None):
|
||||||
# Apply the filter to root logger and specific loggers
|
# Apply the filter to root logger and specific loggers
|
||||||
cancellation_filter = LiteLLMCancellationFilter()
|
cancellation_filter = LiteLLMCancellationFilter()
|
||||||
logging.getLogger().addFilter(cancellation_filter)
|
logging.getLogger().addFilter(cancellation_filter)
|
||||||
logging.getLogger('litellm').addFilter(cancellation_filter)
|
logging.getLogger("litellm").addFilter(cancellation_filter)
|
||||||
|
|
||||||
# Add custom filter to suppress LiteLLM worker cancellation errors
|
# Add custom filter to suppress LiteLLM worker cancellation errors
|
||||||
class LiteLLMFilter(logging.Filter):
|
class LiteLLMFilter(logging.Filter):
|
||||||
def filter(self, record):
|
def filter(self, record):
|
||||||
# Suppress LiteLLM worker cancellation errors
|
# Suppress LiteLLM worker cancellation errors
|
||||||
if hasattr(record, 'msg') and isinstance(record.msg, str):
|
if hasattr(record, "msg") and isinstance(record.msg, str):
|
||||||
msg_lower = record.msg.lower()
|
msg_lower = record.msg.lower()
|
||||||
if any(phrase in msg_lower for phrase in [
|
if any(
|
||||||
'loggingworker cancelled',
|
phrase in msg_lower
|
||||||
'cancellederror',
|
for phrase in [
|
||||||
'logging_worker.py',
|
"loggingworker cancelled",
|
||||||
'loggingerror'
|
"cancellederror",
|
||||||
]):
|
"logging_worker.py",
|
||||||
|
"loggingerror",
|
||||||
|
]
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue