This commit is contained in:
@@ -14,6 +14,8 @@ probably change to something more elegant.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
Any,
|
||||
@@ -31,6 +33,12 @@ from typing import (
|
||||
)
|
||||
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import Self
|
||||
else:
|
||||
from typing_extensions import Self
|
||||
|
||||
|
||||
WrappedLogger = Any
|
||||
"""
|
||||
A logger that is wrapped by a bound logger and is ultimately responsible for
|
||||
@@ -60,11 +68,15 @@ copy itself.
|
||||
.. versionadded:: 20.2.0
|
||||
"""
|
||||
|
||||
Processor = Callable[
|
||||
[WrappedLogger, str, EventDict],
|
||||
Union[Mapping[str, Any], str, bytes, bytearray, Tuple[Any, ...]],
|
||||
ProcessorReturnValue = Union[
|
||||
Mapping[str, Any], str, bytes, bytearray, Tuple[Any, ...]
|
||||
]
|
||||
"""
|
||||
A value returned by a processor.
|
||||
"""
|
||||
|
||||
Processor = Callable[[WrappedLogger, str, EventDict], ProcessorReturnValue]
|
||||
"""
|
||||
A callable that is part of the processor chain.
|
||||
|
||||
See :doc:`processors`.
|
||||
@@ -102,20 +114,17 @@ class ExceptionTransformer(Protocol):
|
||||
Used by `structlog.processors.format_exc_info()` and
|
||||
`structlog.processors.ExceptionPrettyPrinter`.
|
||||
|
||||
Arguments:
|
||||
|
||||
Args:
|
||||
exc_info: Is the exception tuple to format
|
||||
|
||||
Returns:
|
||||
|
||||
Anything that can be rendered by the last processor in your chain,
|
||||
for example, a string or a JSON-serializable structure.
|
||||
Anything that can be rendered by the last processor in your chain, for
|
||||
example, a string or a JSON-serializable structure.
|
||||
|
||||
.. versionadded:: 22.1.0
|
||||
"""
|
||||
|
||||
def __call__(self, exc_info: ExcInfo) -> Any:
|
||||
...
|
||||
def __call__(self, exc_info: ExcInfo) -> Any: ...
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
@@ -129,17 +138,13 @@ class BindableLogger(Protocol):
|
||||
|
||||
_context: Context
|
||||
|
||||
def bind(self, **new_values: Any) -> BindableLogger:
|
||||
...
|
||||
def bind(self, **new_values: Any) -> Self: ...
|
||||
|
||||
def unbind(self, *keys: str) -> BindableLogger:
|
||||
...
|
||||
def unbind(self, *keys: str) -> Self: ...
|
||||
|
||||
def try_unbind(self, *keys: str) -> BindableLogger:
|
||||
...
|
||||
def try_unbind(self, *keys: str) -> Self: ...
|
||||
|
||||
def new(self, **new_values: Any) -> BindableLogger:
|
||||
...
|
||||
def new(self, **new_values: Any) -> Self: ...
|
||||
|
||||
|
||||
class FilteringBoundLogger(BindableLogger, Protocol):
|
||||
@@ -185,6 +190,20 @@ class FilteringBoundLogger(BindableLogger, Protocol):
|
||||
.. versionadded:: 22.1.0
|
||||
"""
|
||||
|
||||
def is_enabled_for(self, level: int) -> bool:
|
||||
"""
|
||||
Check whether the logger is enabled for *level*.
|
||||
|
||||
.. versionadded:: 25.1.0
|
||||
"""
|
||||
|
||||
def get_effective_level(self) -> int:
|
||||
"""
|
||||
Return the effective level of the logger.
|
||||
|
||||
.. versionadded:: 25.1.0
|
||||
"""
|
||||
|
||||
def debug(self, event: str, *args: Any, **kw: Any) -> Any:
|
||||
"""
|
||||
Log ``event % args`` with **kw** at **debug** level.
|
||||
|
||||
Reference in New Issue
Block a user