Skip to content

increase log size to a maximum 8 mb #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions mergin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from typing import List

from .common import ClientError, LoginError, WorkspaceRole, ProjectRole, LOG_FILE_SIZE_TO_SEND, MERGIN_DEFAULT_LOGS_URL
from .common import ClientError, LoginError, WorkspaceRole, ProjectRole, MAX_LOG_FILE_SIZE_TO_SEND, MERGIN_DEFAULT_LOGS_URL
from .merginproject import MerginProject
from .client_pull import (
download_file_finalize,
Expand Down Expand Up @@ -1424,16 +1424,20 @@ def send_logs(
platform.system(), self.url, self.username()
)

# We send more from the local logs
global_logs_file_size_to_send = MAX_LOG_FILE_SIZE_TO_SEND * 0.2
local_logs_file_size_to_send = MAX_LOG_FILE_SIZE_TO_SEND * 0.8

global_logs = b""
if global_log_file and os.path.exists(global_log_file):
with open(global_log_file, "rb") as f:
if os.path.getsize(global_log_file) > LOG_FILE_SIZE_TO_SEND:
f.seek(-LOG_FILE_SIZE_TO_SEND, os.SEEK_END)
if os.path.getsize(global_log_file) > global_logs_file_size_to_send:
f.seek(-global_logs_file_size_to_send, os.SEEK_END)
global_logs = f.read() + b"\n--------------------------------\n\n"

with open(logfile, "rb") as f:
if os.path.getsize(logfile) > 512 * 1024:
f.seek(-512 * 1024, os.SEEK_END)
if os.path.getsize(logfile) > local_logs_file_size_to_send:
f.seek(-local_logs_file_size_to_send, os.SEEK_END)
logs = f.read()

payload = meta.encode() + global_logs + logs
Expand Down
2 changes: 1 addition & 1 deletion mergin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
UPLOAD_CHUNK_SIZE = 10 * 1024 * 1024

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

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