Skip to content

Commit 635d403

Browse files
committed
Log full URL when making requests
1 parent 0ac4135 commit 635d403

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mautrix/api.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ async def _send(
263263
def _log_request(
264264
self,
265265
method: Method,
266-
path: PathBuilder,
266+
url: URL,
267267
content: str | bytes | bytearray | AsyncBody,
268268
orig_content,
269269
query_params: dict[str, str],
@@ -283,15 +283,15 @@ def _log_request(
283283
else:
284284
log_content = content
285285
as_user = query_params.get("user_id", None)
286-
level = 5 if path == Path.v3.sync else 10
286+
level = 5 if url.path.endswith("/v3/sync") else 10
287287
self.log.log(
288288
level,
289-
f"req #{req_id}: {method} /{path} {log_content}".strip(" "),
289+
f"req #{req_id}: {method} {url} {log_content}".strip(" "),
290290
extra={
291291
"matrix_http_request": {
292292
"req_id": req_id,
293293
"method": str(method),
294-
"path": str(path),
294+
"url": str(url),
295295
"content": (
296296
orig_content
297297
if isinstance(orig_content, (dict, list)) and not sensitive
@@ -387,9 +387,10 @@ async def request(
387387
if do_fake_iter:
388388
headers["Content-Length"] = str(len(content))
389389
backoff = 4
390+
log_url = full_url.with_query(query_params)
390391
while True:
391392
self._log_request(
392-
method, path, content, orig_content, query_params, headers, req_id, sensitive
393+
method, log_url, content, orig_content, query_params, headers, req_id, sensitive
393394
)
394395
API_CALLS.labels(method=metrics_method).inc()
395396
req_content = _async_iter_bytes(content) if do_fake_iter else content

0 commit comments

Comments
 (0)