MCPcopy
hub / github.com/tornadoweb/tornado / log_request

Method log_request

tornado/web.py:2421–2444  ·  view source on GitHub ↗

Writes a completed HTTP request to the logs. By default writes to the python root logger. To change this behavior either subclass Application and override this method, or pass a function in the application settings dictionary as ``log_function``.

(self, handler: RequestHandler)

Source from the content-addressed store, hash-verified

2419 raise KeyError("%s not found in named urls" % name)
2420
2421 def log_request(self, handler: RequestHandler) -> None:
2422 """Writes a completed HTTP request to the logs.
2423
2424 By default writes to the python root logger. To change
2425 this behavior either subclass Application and override this method,
2426 or pass a function in the application settings dictionary as
2427 ``log_function``.
2428 """
2429 if "log_function" in self.settings:
2430 self.settings["log_function"](handler)
2431 return
2432 if handler.get_status() < 400:
2433 log_method = access_log.info
2434 elif handler.get_status() < 500:
2435 log_method = access_log.warning
2436 else:
2437 log_method = access_log.error
2438 request_time = 1000.0 * handler.request.request_time()
2439 log_method(
2440 "%d %s %.2fms",
2441 handler.get_status(),
2442 handler._request_summary(),
2443 request_time,
2444 )
2445
2446
2447class _HandlerDelegate(httputil.HTTPMessageDelegate):

Callers 1

_logMethod · 0.80

Calls 3

get_statusMethod · 0.80
request_timeMethod · 0.80
_request_summaryMethod · 0.80

Tested by

no test coverage detected