Add stack information with key ``stack`` if ``stack_info`` is `True`. Useful when you want to attach a stack dump to a log entry without involving an exception and works analogously to the *stack_info* argument of the Python standard library logging. Args: additional_i
| 681 | |
| 682 | |
| 683 | class StackInfoRenderer: |
| 684 | """ |
| 685 | Add stack information with key ``stack`` if ``stack_info`` is `True`. |
| 686 | |
| 687 | Useful when you want to attach a stack dump to a log entry without |
| 688 | involving an exception and works analogously to the *stack_info* argument |
| 689 | of the Python standard library logging. |
| 690 | |
| 691 | Args: |
| 692 | additional_ignores: |
| 693 | By default, stack frames coming from *structlog* are ignored. With |
| 694 | this argument you can add additional names that are ignored, before |
| 695 | the stack starts being rendered. They are matched using |
| 696 | ``startswith()``, so they don't have to match exactly. The names |
| 697 | are used to find the first relevant name, therefore once a frame is |
| 698 | found that doesn't start with *structlog* or one of |
| 699 | *additional_ignores*, **no filtering** is applied to subsequent |
| 700 | frames. |
| 701 | |
| 702 | .. versionadded:: 0.4.0 |
| 703 | .. versionadded:: 22.1.0 *additional_ignores* |
| 704 | """ |
| 705 | |
| 706 | __slots__ = ("_additional_ignores",) |
| 707 | |
| 708 | def __init__(self, additional_ignores: list[str] | None = None) -> None: |
| 709 | self._additional_ignores = additional_ignores |
| 710 | |
| 711 | def __call__( |
| 712 | self, logger: WrappedLogger, name: str, event_dict: EventDict |
| 713 | ) -> EventDict: |
| 714 | if event_dict.pop("stack_info", None): |
| 715 | event_dict["stack"] = _format_stack( |
| 716 | _find_first_app_frame_and_name(self._additional_ignores)[0] |
| 717 | ) |
| 718 | |
| 719 | return event_dict |
| 720 | |
| 721 | |
| 722 | class CallsiteParameter(enum.Enum): |
no outgoing calls
searching dependent graphs…