@@ -17,11 +17,10 @@ void ConfigureSentryWithLogs()
1717 USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem >();
1818
1919 // Create settings with logging enabled
20- USentrySettings* Settings = NewObject<USentrySettings >();
21- Settings->EnableStructuredLogging = true;
22-
23- // Initialize with custom settings
24- SentrySubsystem->InitializeWithSettings(Settings);
20+ SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([ =] (USentrySettings* Settings)
21+ {
22+ Settings - > EnableStructuredLogging = true ;
23+ } ));
2524}
2625```
2726
@@ -32,18 +31,22 @@ void ConfigureSentryWithLogs()
3231You can configure the SDK to automatically forward Unreal Engine's native ` UE_LOG ` calls to Sentry based on the enabled severity levels:
3332
3433``` cpp
34+ USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
35+
3536// Configure automatic log forwarding programmatically
36- USentrySettings* Settings = NewObject<USentrySettings>();
37- Settings->EnableStructuredLogging = true ;
37+ SentrySubsystem->InitializeWithSettings (FConfigureSettingsNativeDelegate::CreateLambda([ =] (USentrySettings* Settings)
38+ {
39+ Settings - > EnableStructuredLogging = true ;
3840
39- // Enable specific severity levels for UE_LOG forwarding
40- Settings->EnableDebugLogs = false ;
41- Settings->EnableInfoLogs = true ;
42- Settings->EnableWarningLogs = true ;
43- Settings->EnableErrorLogs = true ;
44- Settings->EnableFatalLogs = true ;
41+ // Enable specific severity levels for UE_LOG forwarding
42+ Settings - > EnableDebugLogs = false ;
43+ Settings - > EnableInfoLogs = true ;
44+ Settings - > EnableWarningLogs = true ;
45+ Settings - > EnableErrorLogs = true ;
46+ Settings - > EnableFatalLogs = true ;
4547
46- Settings->SendLogsAsBreadcrumbs = false ; // Send as structured logs instead of breadcrumbs
48+ Settings - > bSendBreadcrumbsWithStructuredLogging = false ; // Send as structured logs instead of breadcrumbs
49+ }));
4750` ` `
4851
4952#### Log Category Filtering
@@ -52,20 +55,30 @@ You can filter which log categories are sent to Sentry:
5255
5356` ` ` cpp
5457// Configure category filtering
55- USentrySettings* Settings = NewObject<USentrySettings>();
56- Settings->EnableStructuredLogging = true ;
57-
58- // Only forward logs from specific categories
59- TArray<FString> AllowedCategories;
60- AllowedCategories.Add(TEXT(" LogGameFlow" ));
61- AllowedCategories.Add(TEXT(" LogPlayerSystem" ));
62- AllowedCategories.Add(TEXT(" LogSentrySdk" ));
63- Settings->LogCategoryFilter = AllowedCategories;
58+ USentrySubsystem * SentrySubsystem = GEngine - > GetEngineSubsystem <USentrySubsystem >();
59+
60+ // Create settings with logging enabled
61+ SentrySubsystem - > InitializeWithSettings (FConfigureSettingsNativeDelegate ::CreateLambda ([= ](USentrySettings * Settings )
62+ {
63+ Settings->EnableStructuredLogging = true ;
64+
65+ // Only forward logs from specific categories
66+ TArray<FString> AllowedCategories;
67+ AllowedCategories.Add(TEXT(" LogGameFlow" ));
68+ AllowedCategories.Add(TEXT(" LogPlayerSystem" ));
69+ AllowedCategories.Add(TEXT(" LogSentrySdk" ));
70+ Settings->LogCategoryFilter = AllowedCategories ;
71+
72+ }));
6473` ` `
6574
6675#### Before-Log Handler
6776
68- To filter logs, or update them before they are sent to Sentry, you can create a custom before-log handler class similar to the trace sampler pattern:
77+ To filter logs, or update them before they are sent to Sentry, you can create a custom before-log handler class.
78+
79+ <Alert level="info">
80+ Logging additional messages in the BeforeLog handler can cause recursive call of the handler, resulting in a stack overflow!
81+ </Alert>
6982
7083` ` ` cpp
7184UCLASS ()
0 commit comments