in ecs_logging/_stdlib.py [0:0]
def _record_error_stack_trace(self, record: logging.LogRecord) -> Optional[str]:
# Using stack_info=True will add 'error.stack_trace' even
# if the type is not 'error', exc_info=True only gathers
# when there's an active exception.
if (
record.exc_info
and record.exc_info[2] is not None
and (self._stack_trace_limit is None or self._stack_trace_limit > 0)
):
return (
"".join(format_tb(record.exc_info[2], limit=self._stack_trace_limit))
or None
)
# LogRecord only has 'stack_info' if it's passed via .log(..., stack_info=True)
stack_info = getattr(record, "stack_info", None)
if stack_info:
return str(stack_info)
return None