Selkies
Developer Referencestream_server

PathOnlyAccessLogger

aiohttp access log whose request line carries the path without its query.

The secure-mode session token rides the data WebSocket URL as a query parameter, so the stock request-line atom (which logs path_qs) would write credentials into the access log. The line otherwise has the default shape: remote address, start time, method + path + version, status, body size, Referer and User-Agent.

Attributes

attributeenabledbool

Functions

funclog(self, request, response, time) -> None
Source Code
def log(self, request: web.BaseRequest, response: web.StreamResponse, time: float) -> None:
    try:
        started = datetime.now().astimezone() - timedelta(seconds=time)
        self.logger.info(
            '%s [%s] "%s %s HTTP/%d.%d" %s %s "%s" "%s"',
            request.remote or "-",
            started.strftime("%d/%b/%Y:%H:%M:%S %z"),
            request.method,
            request.path,
            request.version.major,
            request.version.minor,
            response.status,
            response.body_length,
            request.headers.get("Referer", "-"),
            request.headers.get("User-Agent", "-"),
        )
    except Exception:
        self.logger.exception("Error in logging")
paramself
paramrequestweb.BaseRequest
paramresponseweb.StreamResponse
paramtimefloat

Returns

None

On this page

Edit on GitHub