Skip to content

Commit

Permalink
Log: include PID and before_request log for debugging (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Jul 27, 2023
1 parent bc1ef2b commit 2f973a5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mwdb/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from datetime import datetime

from flask import g, request
Expand Down Expand Up @@ -135,6 +136,16 @@ class HashConverter(BaseConverter):
def assign_request_id():
g.request_id = token_hex(16)
g.request_start_time = datetime.utcnow()
getLogger().info(
"before_request",
extra={
"path": request.path,
"arguments": request.args,
"method": request.method,
"remote_addr": request.remote_addr,
"pid": os.getpid(),
},
)


@app.after_request
Expand All @@ -155,6 +166,7 @@ def log_request(response):
"response_time": response_time,
"response_size": response_size,
"remote_addr": request.remote_addr,
"pid": os.getpid(),
},
)

Expand Down

0 comments on commit 2f973a5

Please sign in to comment.