Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Verbose Sentry Logging (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
steviegt6 authored Dec 2, 2022
1 parent a7914d6 commit ea8ce4d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/HoloCure.Launcher.Desktop/Utils/SentryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SentryLogger(LauncherBase game)

private void processLogEntry(LogEntry entry)
{
if (entry.Level < LogLevel.Verbose) return;
if (!shouldSubmitEntry(ref entry)) return;

if (entry.Exception is { } ex)
{
Expand Down Expand Up @@ -91,6 +91,15 @@ private SentryLevel getSentryLevel(LogLevel entryLevel) =>
_ => throw new ArgumentOutOfRangeException(nameof(entryLevel), entryLevel, null)
};

private bool shouldSubmitEntry(ref LogEntry entry)
{
// Modify "[context] Log for [user]" message to omit identifiable name.
// Maybe redact/remove GL logging as well? Could be considered a tracking vector, but it's important info (as is OS type, etc.), so not sure.
if (entry.Level == LogLevel.Verbose && entry.Message.Contains(" Log for ")) entry.Message = entry.Message.Replace(Environment.UserName, "[name removed]");

return true;
}

private bool shouldSubmitException(Exception exception)
{
switch (exception)
Expand All @@ -100,7 +109,7 @@ private bool shouldSubmitException(Exception exception)
const int hr_error_handle_disk_full = unchecked((int)0x80070027);
const int hr_error_disk_full = unchecked((int)0x80070070);

if (ioe.HResult == hr_error_handle_disk_full || ioe.HResult == hr_error_disk_full) return false;
if (ioe.HResult is hr_error_handle_disk_full or hr_error_disk_full) return false;

break;
}
Expand Down

0 comments on commit ea8ce4d

Please sign in to comment.