Skip to content

Commit 1d8a2e9

Browse files
committed
add logs
1 parent 60c9d4b commit 1d8a2e9

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

api/src/main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@
5555
app.include_router(MetadataApiRouter)
5656
app.include_router(SearchApiRouter)
5757

58-
59-
@app.on_event("startup")
60-
async def startup_event():
61-
global_logging_setup()
58+
global_logging_setup()
6259

6360

6461
if __name__ == "__main__":

api/src/middleware/request_context_middleware.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def log_api_access(
6060
"""
6161
Log the API access logs.
6262
"""
63+
self.logger.debug("logging log api access")
6364
latency = time.time() - start_time
6465
request = self.create_http_request(scope, request_context, status_code, content_length, latency)
6566
headers = {k.decode().lower(): v.decode() for k, v in scope.get("headers", [])}
@@ -86,11 +87,14 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
8687
"""
8788
if scope["type"] == "http":
8889
start_time = time.time()
90+
self.logger.debug("Registering starting request time: %s", start_time)
8991
request_context = RequestContext(scope=scope)
9092
_request_context.set(request_context.__dict__)
9193

9294
async def http_send(message):
95+
self.logger.debug("HTTP message type: %s", message[type])
9396
if message["type"] == "http.response.start":
97+
self.logger.debug("HTTP response started")
9498
content_type, content_length = self.extract_response_info(message["headers"])
9599
status_code = message["status"]
96100
self.log_api_access(scope, request_context, status_code, content_length, start_time)

0 commit comments

Comments
 (0)