Skip to content

Commit c55e3ca

Browse files
committed
make body optional in logs
1 parent 17720ff commit c55e3ca

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mystbin/backend/utils/db.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,18 @@ async def put_log(
938938
query = """
939939
INSERT INTO logs VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
940940
"""
941+
try:
942+
body = await request.body()
943+
except:
944+
body = None
941945
await self._do_query(
942946
query,
943947
request.headers.get("X-Forwarded-For", request.client.host),
944948
datetime.datetime.utcnow(),
945949
request.headers.get("CF-RAY"),
946950
request.headers.get("CF-IPCOUNTRY"),
947951
f"{request.method.upper()} {request.url}",
948-
await request.body(),
952+
body,
949953
response.status_code,
950954
str(response.body)
951955
)

mystbin/database/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ CREATE TABLE IF NOT EXISTS logs (
5555
cf_ray TEXT,
5656
cf_country TEXT,
5757
web_route TEXT NOT NULL,
58-
body TEXT NOT NULL,
58+
body TEXT,
5959
response_code INTEGER NOT NULL,
6060
response TEXT NOT NULL
6161
);

0 commit comments

Comments
 (0)