Skip to content

Request Log

Info

For request log usage, see Request Log.

requestlog

Request log management for the MREG API client.

RequestLog

A log of HTTP requests made by the client.

maxsize property

maxsize: int | None

Get the maximum number of records that can be stored in the log.

__init__

__init__(maxsize: int | None = None)

Initialize the request log.

Parameters:

Name Type Description Default
maxsize int | None

Maximum number of records to keep in the log. If None, the log is unbounded.

None

__iter__

__iter__() -> Iterator[RequestRecord]

Iterate over the request records in the log.

__len__

__len__() -> int

Return the number of request records in the log.

add

add(
    response: Response,
    data: JsonMapping | None = None,
    json: Json | None = None,
) -> None

Add a new request record to the log.

clear

clear() -> None

Clear the request log.

get

get(
    *,
    status: int | None = None,
    method: str | None = None,
    url: str | None = None,
    where: Callable[[RequestRecord], bool] | None = None,
) -> list[RequestRecord]

Return all recorded requests, optionally filtered by status, method and/or URL.

Multiple filters can be applied at once, and only requests matching all provided filters will be returned.

More complex filtering can be done by providing a callable to the where parameter, which acts as a predicate function to determine if a request record should be included in the results.

Parameters:

Name Type Description Default
status int | None

If provided, only requests with this status code are returned. Defaults to None.

None
method str | None

If provided, only requests with this HTTP method are returned. Defaults to None.

None
url str | None

If provided, only requests to this URL are returned. Defaults to None.

None
where Callable[[RequestRecord], bool] | None

A predicate function that returns True if the request record should be included.

None

Returns:

Type Description
list[RequestRecord]

list[RequestRecord]: description

Parameters:

Name Type Description Default
status int | None
None
method str | None

If given, return only requests with this HTTP method.

None
url str | None

If given, return only requests to this URL.

None
where Callable[[RequestRecord], bool] | None

If given, return only records for which this callable returns True.

None

Returns:

Type Description
list[RequestRecord]

A list of request records matching the specified filters.

last

last() -> RequestRecord | None

Get the most recent request record, or None if the log is empty.

RequestRecord

Bases: NamedTuple

A complete record of an HTTP request and its response.

Captures all relevant details of an API call including the request parameters, response data, and metadata like status code and URL.

path property

path: str

Get the request path (URL without base).

url property

url: str

Get the full request URL.