main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -15,7 +15,7 @@ import warnings
from typing import Any, Callable, Iterable, Sequence, Type, cast
from ._native import make_filtering_bound_logger
from ._log_levels import make_filtering_bound_logger
from ._output import PrintLoggerFactory
from .contextvars import merge_contextvars
from .dev import ConsoleRenderer, _has_colors, set_exc_info
@@ -63,9 +63,9 @@ class _Configuration:
default_processors: Iterable[Processor] = _BUILTIN_DEFAULT_PROCESSORS[:]
default_context_class: type[Context] = _BUILTIN_DEFAULT_CONTEXT_CLASS
default_wrapper_class: Any = _BUILTIN_DEFAULT_WRAPPER_CLASS
logger_factory: Callable[..., WrappedLogger] = (
_BUILTIN_DEFAULT_LOGGER_FACTORY
)
logger_factory: Callable[
..., WrappedLogger
] = _BUILTIN_DEFAULT_LOGGER_FACTORY
cache_logger_on_first_use: bool = _BUILTIN_CACHE_LOGGER_ON_FIRST_USE
@@ -114,7 +114,8 @@ def get_logger(*args: Any, **initial_values: Any) -> Any:
>>> log.info("hello", x=42)
y=23 x=42 event='hello'
Args:
Arguments:
args:
*Optional* positional arguments that are passed unmodified to the
logger factory. Therefore it depends on the factory what they
@@ -123,6 +124,7 @@ def get_logger(*args: Any, **initial_values: Any) -> Any:
initial_values: Values that are used to pre-populate your contexts.
Returns:
A proxy that creates a correctly configured bound logger when
necessary. The type of that bound logger depends on your configuration
and is `structlog.BoundLogger` by default.
@@ -167,7 +169,8 @@ def wrap_logger(
In other words: selective overwriting of the defaults while keeping some
*is* possible.
Args:
Arguments:
initial_values: Values that are used to pre-populate your contexts.
logger_factory_args:
@@ -175,6 +178,7 @@ def wrap_logger(
the logger factory if not `None`.
Returns:
A proxy that creates a correctly configured bound logger when
necessary.
@@ -213,7 +217,8 @@ def configure(
Use `reset_defaults` to undo your changes.
Args:
Arguments:
processors: The processor chain. See :doc:`processors` for details.
wrapper_class:
@@ -264,6 +269,7 @@ def configure_once(
`configure_once` before.
Raises:
RuntimeWarning: if repeated configuration is attempted.
"""
if not _CONFIG.is_configured:
@@ -309,11 +315,6 @@ class BoundLoggerLazyProxy:
.. versionchanged:: 0.4.0 Added support for *logger_factory_args*.
"""
# fulfill BindableLogger protocol without carrying accidental state
@property
def _context(self) -> dict[str, str]:
return self._initial_values
def __init__(
self,
logger: WrappedLogger | None,
@@ -363,9 +364,7 @@ class BoundLoggerLazyProxy:
# Looks like Protocols ignore definitions of __init__ so we have to
# silence Mypy here.
logger = cls(
_logger,
processors=procs,
context=ctx, # type: ignore[call-arg]
_logger, processors=procs, context=ctx # type: ignore[call-arg]
)
def finalized_bind(**new_values: Any) -> BindableLogger: