logowanie 304
This commit is contained in:
12
app.py
12
app.py
@@ -1109,9 +1109,6 @@ def start_timer():
|
||||
|
||||
@app.after_request
|
||||
def log_request(response):
|
||||
if request.path == "/healthcheck":
|
||||
return response
|
||||
|
||||
ip = get_client_ip()
|
||||
method = request.method
|
||||
path = request.path
|
||||
@@ -1120,9 +1117,12 @@ def log_request(response):
|
||||
start = getattr(request, "_start_time", None)
|
||||
duration = round((time.time() - start) * 1000, 2) if start else "-"
|
||||
agent = request.headers.get("User-Agent", "-")
|
||||
|
||||
log_msg = f'{ip} - "{method} {path}" {status} {length} {duration}ms "{agent}"'
|
||||
app.logger.info(log_msg)
|
||||
if status == 304:
|
||||
app.logger.info(f"REVALIDATED: {ip} - \"{method} {path}\" {status} {length} {duration}ms \"{agent}\"")
|
||||
else:
|
||||
app.logger.info(f'{ip} - "{method} {path}" {status} {length} {duration}ms "{agent}"')
|
||||
app.logger.debug(f"Request headers: {dict(request.headers)}")
|
||||
app.logger.debug(f"Response headers: {dict(response.headers)}")
|
||||
return response
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user