INNER CODE UNIT · Python

init_request_instrument

bobbui/json-logging-python · json_logging/__init__.py:149

def init_request_instrument(app=None, custom_formatter=None, exclude_url_patterns=[],
                            request_response_dto_class=DefaultRequestResponseDTO, read_request_body=False):
    """
    Configure the request instrumentation logging configuration for given web app. Must be called after init method

    If **custom_formatter** is passed, it will use this formatter over the default.

    :param app: current web application instance
    :param custom_formatter: formatter to override default JSONRequestLogFormatter.
    :param request_response_dto_class: request_response_dto_class to override default json_logging.RequestResponseDataExtractor.
    :param read_request_body: FastAPI only. Read each logged request's body before the handler runs and expose it as
        ``request.state.json_logging_request_body`` (bytes), so a custom formatter can use it without ``await``.
        Off by default and never added to the log automatically. The whole body is held in memory.
    """

    if _current_framework is None or _current_framework == '-':
        raise RuntimeError("please init the logging first, call init(framework_name) first")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…