PathOnlyAccessLogger
aiohttp access log whose request line and Referer carry no query.
A secure-mode session token rides a query parameter when the page was
opened with ?token=: on the data WebSocket URL, the file-manager
listing, and the Referer of every request that page makes. The stock
request-line atom (which logs path_qs) would write it into the access
log, and so would the Referer, so both are logged without their query. The
line otherwise has the default shape: remote address, start time, method +
path + version, status, body size, Referer, and User-Agent.
Attributes
attributeenabledboolFunctions
funclog(request, response, time) -> NoneSource 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", "-").split("?", 1)[0].split("#", 1)[0],
request.headers.get("User-Agent", "-"),
)
except Exception:
self.logger.exception("Error in logging")paramrequestweb.BaseRequestparamresponseweb.StreamResponseparamtimefloatReturns
None