API refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-07 16:25:52 +09:00
parent 76d0d86211
commit 91c7e04474
1171 changed files with 81940 additions and 44117 deletions

View File

@@ -24,7 +24,6 @@ from zope.interface import implementer
from ._base import BoundLoggerBase
from ._config import _BUILTIN_DEFAULT_PROCESSORS
from ._utils import until_not_interrupted
from .processors import JSONRenderer as GenericJSONRenderer
from .typing import EventDict, WrappedLogger
@@ -204,8 +203,7 @@ class PlainFileLogObserver:
Great to just print JSON to stdout where you catch it with something like
runit.
Arguments:
Args:
file: File to print to.
.. versionadded:: 0.2.0
@@ -216,12 +214,11 @@ class PlainFileLogObserver:
self._flush = file.flush
def __call__(self, eventDict: EventDict) -> None:
until_not_interrupted(
self._write,
self._write(
textFromEventDict(eventDict) # type: ignore[arg-type, operator]
+ "\n",
)
until_not_interrupted(self._flush)
self._flush()
@implementer(ILogObserver)
@@ -229,8 +226,7 @@ class JSONLogObserverWrapper:
"""
Wrap a log *observer* and render non-`JSONRenderer` entries to JSON.
Arguments:
Args:
observer (ILogObserver):
Twisted log observer to wrap. For example
:class:`PlainFileObserver` or Twisted's stock `FileLogObserver
@@ -293,8 +289,7 @@ class EventAdapter:
<https://docs.twisted.org/en/stable/api/twisted.python.log.html#err>`_
behave as expected.
Arguments:
Args:
dictRenderer:
Renderer that is used for the actual log message. Please note that
structlog comes with a dedicated `JSONRenderer`.
@@ -306,8 +301,9 @@ class EventAdapter:
def __init__(
self,
dictRenderer: Callable[[WrappedLogger, str, EventDict], str]
| None = None,
dictRenderer: (
Callable[[WrappedLogger, str, EventDict], str] | None
) = None,
) -> None:
self._dictRenderer = dictRenderer or _BUILTIN_DEFAULT_PROCESSORS[-1]