mirror of
https://github.com/simple-login/app.git
synced 2024-11-10 17:35:27 +08:00
logging time for each request
This commit is contained in:
parent
cbd6c96d01
commit
8583615ba1
1 changed files with 13 additions and 1 deletions
14
server.py
14
server.py
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import os
|
||||
import time
|
||||
from datetime import timedelta
|
||||
|
||||
import arrow
|
||||
|
@ -448,6 +449,16 @@ def set_index_page(app):
|
|||
else:
|
||||
return redirect(url_for("auth.login"))
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
# not logging /static call
|
||||
if (
|
||||
not request.path.startswith("/static")
|
||||
and not request.path.startswith("/admin/static")
|
||||
and not request.path.startswith("/_debug_toolbar")
|
||||
):
|
||||
g.start_time = time.time()
|
||||
|
||||
@app.after_request
|
||||
def after_request(res):
|
||||
# not logging /static call
|
||||
|
@ -457,12 +468,13 @@ def set_index_page(app):
|
|||
and not request.path.startswith("/_debug_toolbar")
|
||||
):
|
||||
LOG.debug(
|
||||
"%s %s %s %s %s",
|
||||
"%s %s %s %s %s, takes %s",
|
||||
request.remote_addr,
|
||||
request.method,
|
||||
request.path,
|
||||
request.args,
|
||||
res.status_code,
|
||||
time.time() - g.start_time,
|
||||
)
|
||||
|
||||
return res
|
||||
|
|
Loading…
Reference in a new issue