Skip to content

Commit

Permalink
Fix event capturing on Linux (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustanivsky authored Oct 11, 2022
1 parent a11d155 commit eed931f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,15 @@ jobs:
docker logout ghcr.io
# Add the user so it has a home directory (needed for the pip cache later on)
docker exec --user root unreal useradd -u $uid -g $gid --create-home $user
# Ensure CA certs are in the right directory (needed for running tests)
docker exec --user root unreal bash -c "
mkdir -p /etc/pki/tls/certs ;
cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt "
# Chown some paths to the GH user to make UE5 work properly. We can't just chown the whole UnrealEngine or
# docker would implicitly have to copy it to the container and we would run out of space on the GH runner.
docker exec --user root unreal bash -c "
chown -R $uid /home/ue4/UnrealEngine/Engine/Binaries/ThirdParty/Mono/Linux ;
chown -R $uid /home/ue4/UnrealEngine/Engine/Programs/UnrealPak/Saved"
chown -R $uid /home/ue4/UnrealEngine/Engine/Programs/UnrealPak/Saved "
- name: Setup UE CLI
run: docker exec unreal bash -c '
Expand All @@ -186,6 +190,10 @@ jobs:
- name: Extract package to ${{ matrix.app }}/Plugins
run: unzip sentry-unreal-*-engine${{ matrix.unreal }}.zip -d checkout/${{ matrix.app }}/Plugins/sentry

- name: Set permissions for ${{ matrix.app }}
# sentry-native requires write access to sample project directory in order to initialize itself properly
run: docker exec -w /workspace/checkout unreal chmod -R +x ${{ matrix.app }}

- name: Run tests
run: docker exec -w /workspace/checkout/${{ matrix.app }} unreal ue4 test --filter Product

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Sentry libs linking for desktop ([#114](https://github.com/getsentry/sentry-unreal/pull/114))
- Fix sentry-cocoa SDK name ([#118](https://github.com/getsentry/sentry-unreal/pull/118))
- Fix scoped event/message capturing on Android ([#116](https://github.com/getsentry/sentry-unreal/pull/116))
- Fix event capturing on Linux ([#123](https://github.com/getsentry/sentry-unreal/pull/123))
- Fix incomplete type forward declaration ([#125](https://github.com/getsentry/sentry-unreal/pull/125))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
#include "SentryUser.h"
#include "SentryModule.h"

#include "Convenience/SentryInclude.h"
#include "Infrastructure/SentryConvertorsDesktop.h"
#include "CrashReporter/SentryCrashReporter.h"

#include "Misc/Paths.h"

void PrintVerboseLog(sentry_level_t level, const char *message, va_list args, void *userdata)
{
char buffer[512];
vsnprintf(buffer, 512, message, args);

UE_LOG(LogSentrySdk, Log, TEXT("%s"), *FString(buffer));
}

SentrySubsystemDesktop::SentrySubsystemDesktop()
{
crashReporter = MakeShareable(new SentryCrashReporter);
Expand All @@ -40,11 +47,19 @@ void SentrySubsystemDesktop::InitWithSettings(const USentrySettings* settings)
return;
}

const FString DatabasePath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForWrite(*FPaths::Combine(FPaths::ProjectDir(), TEXT(".sentry-native")));

sentry_options_t* options = sentry_options_new();
sentry_options_set_dsn(options, TCHAR_TO_ANSI(*settings->DsnUrl));
sentry_options_set_release(options, TCHAR_TO_ANSI(*settings->Release));
sentry_options_set_handler_path(options, TCHAR_TO_ANSI(*HandlerPath));
sentry_init(options);
sentry_options_set_database_path(options, TCHAR_TO_ANSI(*DatabasePath));
sentry_options_set_logger(options, PrintVerboseLog, nullptr);
sentry_options_set_debug(options, settings->EnableVerboseLogging);

int initResult = sentry_init(options);

UE_LOG(LogSentrySdk, Log, TEXT("Sentry initialization completed with result %d (0 on success)."), initResult);

crashReporter->SetRelease(settings->Release);
}
Expand Down Expand Up @@ -144,4 +159,4 @@ void SentrySubsystemDesktop::RemoveTag(const FString& key)
void SentrySubsystemDesktop::SetLevel(ESentryLevel level)
{
sentry_set_level(SentryConvertorsDesktop::SentryLevelToNative(level));
}
}
1 change: 1 addition & 0 deletions plugin-dev/Source/Sentry/Private/SentrySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
USentrySettings::USentrySettings(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, InitAutomatically(false)
, EnableVerboseLogging(true)
, UploadSymbolsAutomatically(false)
{
DsnUrl = TEXT("");
Expand Down
4 changes: 4 additions & 0 deletions plugin-dev/Source/Sentry/Public/SentrySettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class SENTRY_API USentrySettings : public UObject
Meta = (DisplayName = "Initialize SDK automatically", ToolTip = "Flag indicating whether to automatically initialize the SDK when the app starts."))
bool InitAutomatically;

UPROPERTY(Config, EditAnywhere, Category = "Misc",
Meta = (DisplayName = "Enable verbose logging", ToolTip = "Flag indicating whether to enable verbose logging on desktop."))
bool EnableVerboseLogging;

UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "Misc",
Meta = (DisplayName = "Automatically add breadcrumbs"))
FAutomaticBreadcrumbs AutomaticBreadcrumbs;
Expand Down

0 comments on commit eed931f

Please sign in to comment.