mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
refactor(logging): hoist a safely-hoistable function-body import to module top
CorrelationContextFilter.filter()'s `import litellm` was a function-body import; verified it can move to module top without a circular-import failure (litellm/__init__.py already imports from litellm._logging before setting request_correlation_in_logs, but a bare `import litellm` only binds the already-in-sys.modules module object - the attribute itself isn't read until filter() actually runs, by which point litellm is fully initialized).
This commit is contained in:
parent
0f129ad31b
commit
5fe7041c8d
1 changed files with 2 additions and 2 deletions
|
|
@ -3,6 +3,8 @@ import contextvars
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
import litellm
|
||||
from datetime import datetime
|
||||
from logging import Formatter
|
||||
from typing import Any, Final
|
||||
|
|
@ -113,8 +115,6 @@ class CorrelationContextFilter(logging.Filter):
|
|||
"""
|
||||
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
import litellm
|
||||
|
||||
if not litellm.request_correlation_in_logs:
|
||||
return True
|
||||
trace_id = trace_id_var.get()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue