Skip to content

Commit f45f5ea

Browse files
authored
Add option to disable LogError capturing (#2009)
1 parent 699c55e commit f45f5ea

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/Sentry.Unity.Editor/ConfigurationWindow/EnrichmentTab.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ internal static void Display(ScriptableSentryUnityOptions options)
6363
EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray);
6464
EditorGUILayout.Space();
6565

66+
options.CaptureLogErrorEvents = EditorGUILayout.Toggle(
67+
new GUIContent("Capture LogError as Event", "Whether the SDK automatically captures events for 'Debug.LogError'."),
68+
options.CaptureLogErrorEvents);
69+
6670
GUILayout.Label("Breadcrumbs automatically added for LogType:", EditorStyles.boldLabel);
6771

6872
options.BreadcrumbsForLogs = EditorGUILayout.Toggle(

src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ internal void OnLogMessageReceived(string message, string stacktrace, LogType lo
7070
}
7171
}
7272

73-
if (logType is LogType.Error)
73+
if (logType is LogType.Error && _options?.CaptureLogErrorEvents is true)
7474
{
7575
if (_options?.AttachStacktrace is true && !string.IsNullOrEmpty(stacktrace))
7676
{

src/Sentry.Unity/ScriptableSentryUnityOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null)
6363
[field: SerializeField] public bool BreadcrumbsForAsserts { get; set; } = true;
6464
[field: SerializeField] public bool BreadcrumbsForErrors { get; set; } = true;
6565
[field: SerializeField] public bool BreadcrumbsForExceptions { get; set; } = true;
66+
[field: SerializeField] public bool CaptureLogErrorEvents { get; set; } = true;
6667

6768
[field: SerializeField] public int MaxBreadcrumbs { get; set; } = SentryConstants.DefaultMaxBreadcrumbs;
6869

@@ -169,6 +170,7 @@ internal SentryUnityOptions ToSentryUnityOptions(bool isBuilding, ISentryUnityIn
169170
// need to set it here directly.
170171
Debug = ShouldDebug(application.IsEditor && !isBuilding),
171172
DiagnosticLevel = DiagnosticLevel,
173+
CaptureLogErrorEvents = CaptureLogErrorEvents,
172174
AnrTimeout = TimeSpan.FromMilliseconds(AnrTimeout),
173175
CaptureFailedRequests = CaptureFailedRequests,
174176
FilterBadGatewayExceptions = FilterBadGatewayExceptions,

src/Sentry.Unity/SentryUnityOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ public sealed class SentryUnityOptions : SentryOptions
129129
/// </summary>
130130
public int ScreenshotCompression { get; set; } = 75;
131131

132+
/// <summary>
133+
/// Whether the SDK automatically captures events for 'Debug.LogError'.
134+
/// </summary>
135+
public bool CaptureLogErrorEvents { get; set; } = true;
136+
132137
/// <summary>
133138
/// Whether the SDK should automatically add breadcrumbs per LogType
134139
/// </summary>

0 commit comments

Comments
 (0)