mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 22:50:18 +00:00
Update simplemind/logging.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -46,14 +46,19 @@ def logger(func: Callable[..., Any]) -> Callable[..., Any]:
|
||||
)
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
if not settings.logging.is_enabled:
|
||||
return func(*args, **kwargs)
|
||||
|
||||
chunks = []
|
||||
try:
|
||||
is_streaming = "generate_stream_text" in func.__name__ or kwargs.get("stream")
|
||||
logfire.error(
|
||||
"{event}",
|
||||
event="function failed",
|
||||
error=str(e),
|
||||
duration=time.perf_counter() - t1,
|
||||
streamed_chunks=len(chunks) if is_streaming else None,
|
||||
partial_streaming_result="".join(chunks)[:2000] if is_streaming else None,
|
||||
streamed_chunks=len(chunks) if chunks else None,
|
||||
partial_streaming_result="".join(chunks)[:2000] if chunks else None,
|
||||
)
|
||||
raise e
|
||||
|
||||
|
||||
Reference in New Issue
Block a user