diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index c0fdd3090c..6a8a6cfdc1 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -1607,6 +1607,7 @@ class Logging: ) == False ): # custom logger class + callback.log_failure_event( start_time=start_time, end_time=end_time, diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 4665bbce7c..32b74be7c6 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -585,23 +585,24 @@ class ProxyLogging: **request_data, ) - # log the custom exception - await litellm_logging_obj.async_failure_handler( - exception=original_exception, - traceback_exception=traceback.format_exc(), - start_time=time.time(), - end_time=time.time(), - ) + if litellm_logging_obj is not None: + # log the custom exception + await litellm_logging_obj.async_failure_handler( + exception=original_exception, + traceback_exception=traceback.format_exc(), + start_time=time.time(), + end_time=time.time(), + ) - threading.Thread( - target=litellm_logging_obj.failure_handler, - args=( - original_exception, - traceback.format_exc(), - time.time(), - time.time(), - ), - ).start() + threading.Thread( + target=litellm_logging_obj.failure_handler, + args=( + original_exception, + traceback.format_exc(), + time.time(), + time.time(), + ), + ).start() for callback in litellm.callbacks: try: diff --git a/litellm/tests/test_proxy_reject_logging.py b/litellm/tests/test_proxy_reject_logging.py index b1796abee6..865566d009 100644 --- a/litellm/tests/test_proxy_reject_logging.py +++ b/litellm/tests/test_proxy_reject_logging.py @@ -76,7 +76,7 @@ class testLogger(CustomLogger): self.reaches_async_failure_event = True def log_failure_event(self, kwargs, response_obj, start_time, end_time): - self.reaches_failure_event = True + self.reaches_sync_failure_event = True router = Router( @@ -186,4 +186,5 @@ async def test_chat_completion_request_with_redaction(route, body): await asyncio.sleep(3) assert _test_logger.reaches_async_failure_event is True + assert _test_logger.reaches_sync_failure_event is True