Skip to content

Commit b912616

Browse files
authored
Merge pull request #250 from MerginMaps/increase-log-size
increase log size to a maximum 8 mb
2 parents 40f0ee8 + 3964291 commit b912616

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

mergin/client.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919

2020
from typing import List
2121

22-
from .common import ClientError, LoginError, WorkspaceRole, ProjectRole, LOG_FILE_SIZE_TO_SEND, MERGIN_DEFAULT_LOGS_URL
22+
from .common import (
23+
ClientError,
24+
LoginError,
25+
WorkspaceRole,
26+
ProjectRole,
27+
MAX_LOG_FILE_SIZE_TO_SEND,
28+
MERGIN_DEFAULT_LOGS_URL,
29+
)
2330
from .merginproject import MerginProject
2431
from .client_pull import (
2532
download_file_finalize,
@@ -1410,16 +1417,20 @@ def send_logs(
14101417
platform.system(), self.url, self.username()
14111418
)
14121419

1420+
# We send more from the local logs
1421+
global_logs_file_size_to_send = MAX_LOG_FILE_SIZE_TO_SEND * 0.2
1422+
local_logs_file_size_to_send = MAX_LOG_FILE_SIZE_TO_SEND * 0.8
1423+
14131424
global_logs = b""
14141425
if global_log_file and os.path.exists(global_log_file):
14151426
with open(global_log_file, "rb") as f:
1416-
if os.path.getsize(global_log_file) > LOG_FILE_SIZE_TO_SEND:
1417-
f.seek(-LOG_FILE_SIZE_TO_SEND, os.SEEK_END)
1427+
if os.path.getsize(global_log_file) > global_logs_file_size_to_send:
1428+
f.seek(-global_logs_file_size_to_send, os.SEEK_END)
14181429
global_logs = f.read() + b"\n--------------------------------\n\n"
14191430

14201431
with open(logfile, "rb") as f:
1421-
if os.path.getsize(logfile) > 512 * 1024:
1422-
f.seek(-512 * 1024, os.SEEK_END)
1432+
if os.path.getsize(logfile) > local_logs_file_size_to_send:
1433+
f.seek(-local_logs_file_size_to_send, os.SEEK_END)
14231434
logs = f.read()
14241435

14251436
payload = meta.encode() + global_logs + logs

mergin/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
UPLOAD_CHUNK_SIZE = 10 * 1024 * 1024
88

99
# size of the log file part to send (if file is larger only this size from end will be sent)
10-
LOG_FILE_SIZE_TO_SEND = 100 * 1024
10+
MAX_LOG_FILE_SIZE_TO_SEND = 8 * 1024 * 1024
1111

1212
# default URL for submitting logs
1313
MERGIN_DEFAULT_LOGS_URL = "https://g4pfq226j0.execute-api.eu-west-1.amazonaws.com/mergin_client_log_submit"

0 commit comments

Comments
 (0)