Skip to content
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

Improve logging when copying Apple crash reports #871

Merged
merged 2 commits into from
May 2, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public async Task EndCaptureAsync(TimeSpan timeout)
}
else
{

Thread.Sleep(TimeSpan.FromSeconds(1));
await Task.Delay(TimeSpan.FromSeconds(1));
}

continue;
Expand All @@ -101,27 +100,30 @@ public async Task EndCaptureAsync(TimeSpan timeout)
foreach (var path in newCrashFiles)
{
// It can happen that the crash log is still being written to so we have to retry
int retry = 0;
int retry = 1;
while (true)
{
try
{
_logs.AddFile(path, $"Crash report: {Path.GetFileName(path)}");
var fileName = Path.GetFileName(path);
_log.WriteLine($" - Adding {path}");
_logs.AddFile(path, $"Crash report: {fileName}");
_log.WriteLine($" Successfully copied {fileName}");
break;
}
catch (Exception e)
{
_log.WriteLine($"Failed to copy a crash report {path}: {e.Message}");
_log.WriteLine($" Attempt {retry} to copy a crash report failed: {e.Message}");
}

if (retry == 3)
{
_log.WriteLine($"Failed to copy a crash report after {retry} retries, skipping {path}");
_log.WriteLine($" Failed to copy a crash report after {retry} retries");
break;
}

++retry;
Thread.Sleep(TimeSpan.FromSeconds(2 * retry));
await Task.Delay(TimeSpan.FromSeconds(2 * retry));
}
}
}
Expand Down