mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix: use redacted exc_text in JsonFormatter, snapshot dict iteration in filter
JsonFormatter.format() was calling self.formatException(record.exc_info) directly, bypassing the already-redacted record.exc_text set by SecretRedactionFilter. Now uses record.exc_text when available. Also snapshot record.__dict__.items() with list() as defensive measure against potential dict mutation during iteration.
This commit is contained in:
parent
ff5bd96b59
commit
5e147c685d
1 changed files with 2 additions and 2 deletions
|
|
@ -87,7 +87,7 @@ class SecretRedactionFilter(logging.Filter):
|
|||
pass
|
||||
|
||||
# Redact extra fields passed via logger.debug("msg", extra={...})
|
||||
for key, value in record.__dict__.items():
|
||||
for key, value in list(record.__dict__.items()):
|
||||
if key not in _STANDARD_RECORD_ATTRS and isinstance(value, str):
|
||||
setattr(record, key, _redact_string(value))
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ class JsonFormatter(Formatter):
|
|||
json_record[key] = value
|
||||
|
||||
if record.exc_info:
|
||||
json_record["stacktrace"] = self.formatException(record.exc_info)
|
||||
json_record["stacktrace"] = record.exc_text or self.formatException(record.exc_info)
|
||||
|
||||
return safe_dumps(json_record)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue