Skip to content

Commit

Permalink
Strengthen code & add debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
limbonaut committed Nov 29, 2024
1 parent f3d87a6 commit 8739e08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ void _init_logger() {
return;
}
// Add experimental logger to scene tree.
SentryLogger *logger = memnew(SentryLogger);
SceneTree *sml = Object::cast_to<SceneTree>(Engine::get_singleton()->get_main_loop());
if (sml) {
sml->get_root()->add_child(logger);
if (sml && sml->get_root()) {
sml->get_root()->add_child(memnew(SentryLogger));
} else {
ERR_FAIL_MSG("Sentry: Internal error: SceneTree is null.");
}
Expand Down Expand Up @@ -56,8 +55,12 @@ void initialize_module(ModuleInitializationLevel p_level) {

void uninitialize_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
memdelete(SentrySDK::get_singleton());
delete SentryOptions::get_singleton();
if (SentrySDK::get_singleton()) {
memdelete(SentrySDK::get_singleton());
}
if (SentryOptions::get_singleton()) {
delete SentryOptions::get_singleton();
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/sentry_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void SentrySDK::set_context(const godot::String &p_key, const godot::Dictionary
}

void SentrySDK::_init_contexts() {
sentry::util::print_debug("initializing contexts");
internal_sdk->set_context("device", sentry::contexts::make_device_context(runtime_config));
internal_sdk->set_context("app", sentry::contexts::make_app_context());
internal_sdk->set_context("gpu", sentry::contexts::make_gpu_context());
Expand Down Expand Up @@ -121,6 +122,7 @@ SentrySDK::SentrySDK() {

enabled = enabled && SentryOptions::get_singleton()->is_enabled();
if (!enabled) {
sentry::util::print_debug("Sentry SDK is DISABLED! Operations with Sentry SDK will result in no-ops.");
internal_sdk = std::make_shared<DisabledSDK>();
return;
}
Expand Down

0 comments on commit 8739e08

Please sign in to comment.