Add detailed log for upload failures

The commit introduces more detailed log events when an attempted upload fails for any reason. Now, when there is a non-null status code like 401 or 403, it will log more information, including the decoded content of the HTTP response. This aids in quickly identifying and resolving upload issues.
This commit is contained in:
DevTekVE
2024-05-29 09:54:49 +02:00
parent ab0a10cd9c
commit 4f5251f951
+4 -1
View File
@@ -198,7 +198,10 @@ class Uploader:
cloudlog.event("upload_success", key=key, fn=fn, sz=sz, content_length=content_length,
network_type=network_type, metered=metered, speed=speed)
success = True
else: # 401, 403... Not sure why they were up to begin with
elif stat is not None: # 401, 403... Not sure why they were up to begin with
success = False
cloudlog.event("upload_failed with content", stat=stat, exc=last_exc, key=key, fn=fn, sz=sz, network_type=network_type, metered=metered, error=stat.content.decode("utf-8"))
else:
success = False
cloudlog.event("upload_failed", stat=stat, exc=last_exc, key=key, fn=fn, sz=sz, network_type=network_type, metered=metered)