Skip to content

Commit 33baec0

Browse files
committed
🔄 refactor: Remove unnecessary API logging due to the presence of logging middleware
1 parent 8f84427 commit 33baec0

File tree

4 files changed

+4
-14
lines changed

4 files changed

+4
-14
lines changed

‎api/entry.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ async def startup_event():
3636

3737
@app.middleware("http")
3838
async def log_requests(request: Request, call_next):
39-
logger.info(
40-
f"Received request: {request.client.host} {request.method} {request.url.path}"
41-
)
4239
t1 = time.time()
4340
response = await call_next(request)
4441
t2 = time.time()
45-
logger.info(f"Cost {(t2 - t1) * 1e3:.2f} ms {response.status_code=}")
42+
logger.info(
43+
f"Received request: {request.client.host} {request.method} {request.url.path} "
44+
f"Cost {(t2 - t1) * 1e3:.2f} ms {response.status_code=}"
45+
)
4646
return response

‎api/routers/contest_records.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import List, Optional
33

44
from fastapi import APIRouter, Request
5-
from loguru import logger
65
from pydantic import BaseModel, NonNegativeInt, conint, conlist
76

87
from api.utils import check_contest_name
@@ -30,7 +29,6 @@ async def contest_records_count(
3029
:param archived:
3130
:return:
3231
"""
33-
logger.info(f"{request.client=}")
3432
await check_contest_name(contest_name)
3533
if not archived:
3634
total_num = await ContestRecordPredict.find(
@@ -64,7 +62,6 @@ async def contest_records(
6462
:param limit:
6563
:return:
6664
"""
67-
logger.info(f"{request.client=}")
6865
await check_contest_name(contest_name)
6966
if not archived:
7067
records = (
@@ -108,7 +105,6 @@ async def contest_records_user(
108105
:param archived:
109106
:return:
110107
"""
111-
logger.info(f"{request.client=}")
112108
await check_contest_name(contest_name)
113109
if not archived:
114110
records = await ContestRecordPredict.find(
@@ -147,7 +143,6 @@ async def predicted_rating(
147143
:param query:
148144
:return:
149145
"""
150-
logger.info(f"{request.client=} {request.url.path=}")
151146
await check_contest_name(query.contest_name)
152147
tasks = (
153148
ContestRecordPredict.find_one(
@@ -181,7 +176,6 @@ async def real_time_rank(
181176
:param query:
182177
:return:
183178
"""
184-
logger.info(f"{request.client=}")
185179
await check_contest_name(query.contest_name)
186180
return await ContestRecordArchive.find_one(
187181
ContestRecordArchive.contest_name == query.contest_name,

‎api/routers/contests.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import List, Optional
33

44
from fastapi import APIRouter, Request
5-
from loguru import logger
65
from pydantic import BaseModel, NonNegativeInt, conint
76

87
from app.db.models import Contest
@@ -56,7 +55,6 @@ async def contests_count(
5655
:param archived:
5756
:return:
5857
"""
59-
logger.info(f"{request.client=}")
6058
if archived:
6159
total_num = await Contest.count()
6260
else:
@@ -83,7 +81,6 @@ async def contests(
8381
:param limit:
8482
:return:
8583
"""
86-
logger.info(f"{request.client=}")
8784
if archived:
8885
records = (
8986
await Contest.find_all()

‎api/routers/questions.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ async def questions(
3333
:param query:
3434
:return:
3535
"""
36-
logger.info(f"{request.client=}")
3736
if not (bool(query.contest_name) ^ bool(query.question_id_list)):
3837
msg = "contest_name OR question_id_list must be given!"
3938
logger.error(msg)

0 commit comments

Comments
 (0)