Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/sentry-native
Submodule sentry-native updated 70 files
+1 −1 .github/workflows/benchmark.yml
+6 −2 .github/workflows/ci.yml
+3 −1 .github/workflows/danger.yml
+34 −0 CHANGELOG.md
+39 −11 CMakeLists.txt
+42 −9 examples/example.c
+1 −1 external/breakpad
+1 −1 external/crashpad
+225 −141 include/sentry.h
+1 −1 ndk/gradle.properties
+2 −4 scripts/bump-version.sh
+6 −0 src/CMakeLists.txt
+10 −9 src/backends/sentry_backend_breakpad.cpp
+58 −35 src/backends/sentry_backend_crashpad.cpp
+93 −23 src/backends/sentry_backend_inproc.c
+2 −2 src/modulefinder/sentry_modulefinder_windows.c
+40 −1 src/path/sentry_path.c
+2 −31 src/path/sentry_path_unix.c
+295 −163 src/path/sentry_path_windows.c
+2 −2 src/process/sentry_process_none.c
+37 −30 src/process/sentry_process_windows.c
+0 −4 src/screenshot/sentry_screenshot.c
+9 −6 src/screenshot/sentry_screenshot_windows.c
+11 −19 src/sentry_core.c
+31 −0 src/sentry_cpu_relax.h
+1 −6 src/sentry_database.c
+2 −2 src/sentry_embedded_info.cpp.in
+4 −13 src/sentry_envelope.c
+145 −48 src/sentry_logs.c
+7 −0 src/sentry_logs.h
+21 −0 src/sentry_options.c
+4 −0 src/sentry_options.h
+43 −24 src/sentry_path.h
+2 −2 src/sentry_process.h
+87 −9 src/sentry_string.c
+11 −0 src/sentry_string.h
+9 −1 src/sentry_sync.c
+8 −0 src/sentry_sync.h
+9 −0 src/sentry_transport.c
+8 −0 src/sentry_transport.h
+1 −6 src/sentry_unix_spinlock.h
+45 −0 src/sentry_value.c
+11 −2 src/transports/sentry_transport_winhttp.c
+51 −5 tests/__init__.py
+3 −2 tests/assertions.py
+0 −1 tests/benchmark.py
+16 −2 tests/cmake.py
+25 −0 tests/fixtures/crash_reporter/crash_reporter.c
+7 −4 tests/fixtures/dotnet_signal/Program.cs
+1 −1 tests/proxy.py
+1 −0 tests/requirements.txt
+3 −3 tests/test_build_static.py
+138 −1 tests/test_dotnet_signals.py
+95 −7 tests/test_embedded_info.py
+154 −119 tests/test_integration_crashpad.py
+133 −91 tests/test_integration_http.py
+1 −3 tests/test_integration_logger.py
+5 −5 tests/test_integration_ratelimits.py
+2 −10 tests/test_integration_screenshot.py
+1 −35 tests/test_integration_stdout.py
+13 −5 tests/test_unit.py
+70 −14 tests/unit/test_basic.c
+38 −2 tests/unit/test_embedded_info.c
+0 −1 tests/unit/test_fuzzfailures.c
+99 −28 tests/unit/test_logs.c
+34 −28 tests/unit/test_path.c
+1 −1 tests/unit/test_process.c
+105 −0 tests/unit/test_value.c
+4 −0 tests/unit/tests.inc
+3 −3 tests/win_utils.py
3 changes: 3 additions & 0 deletions project/main.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
extends Node

func _ready() -> void:
SentrySDK.logger.info("Starting UI on {platform}", {
platform=OS.get_name()
})
if OS.get_name() in ["Android", "iOS"]:
get_tree().change_scene_to_file.call_deferred("res://mobile.tscn")
else:
Expand Down
27 changes: 19 additions & 8 deletions src/sentry/native/native_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,36 @@ void NativeSDK::log(LogLevel p_level, const String &p_body, const Dictionary &p_

String body = p_body;

// TODO: Native doesn't support passing attributes yet.
// See: https://github.com/getsentry/sentry-native/issues/1405
sentry_value_t attributes;

if (p_attributes.is_empty()) {
attributes = sentry_value_new_null();
} else {
attributes = sentry_value_new_object();
for (const Variant &key : p_attributes.keys()) {
sentry_value_set_by_key(attributes, key.stringify().utf8(),
variant_to_attribute(p_attributes[key]));
}
}

switch (p_level) {
case LOG_LEVEL_TRACE: {
sentry_log_trace(body.utf8());
sentry_log_trace(body.utf8(), attributes);
} break;
case LOG_LEVEL_DEBUG: {
sentry_log_debug(body.utf8());
sentry_log_debug(body.utf8(), attributes);
} break;
case LOG_LEVEL_INFO: {
sentry_log_info(body.utf8());
sentry_log_info(body.utf8(), attributes);
} break;
case LOG_LEVEL_WARN: {
sentry_log_warn(body.utf8());
sentry_log_warn(body.utf8(), attributes);
} break;
case LOG_LEVEL_ERROR: {
sentry_log_error(body.utf8());
sentry_log_error(body.utf8(), attributes);
} break;
case LOG_LEVEL_FATAL: {
sentry_log_fatal(body.utf8());
sentry_log_fatal(body.utf8(), attributes);
} break;
}
}
Expand Down Expand Up @@ -404,6 +413,8 @@ void NativeSDK::init(const PackedStringArray &p_global_attachments, const Callab
}
}

sentry_options_set_logs_with_attributes(options, true);

// Hooks.
sentry_options_set_before_send(options, _handle_before_send, NULL);
sentry_options_set_on_crash(options, _handle_on_crash, NULL);
Expand Down
14 changes: 4 additions & 10 deletions src/sentry/native/native_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,20 @@ Level cstring_to_level(const CharString &p_cstring) {
}

sentry_value_t variant_to_attribute(const Variant &p_value) {
sentry_value_t obj = sentry_value_new_object();
switch (p_value.get_type()) {
case Variant::BOOL: {
sentry_value_set_by_key(obj, "type", sentry_value_new_string("boolean"));
sentry_value_set_by_key(obj, "value", sentry_value_new_bool((bool)p_value));
return sentry_value_new_attribute(sentry_value_new_bool((bool)p_value), NULL);
} break;
case Variant::INT: {
sentry_value_set_by_key(obj, "type", sentry_value_new_string("integer"));
sentry_value_set_by_key(obj, "value", sentry_value_new_int64((int64_t)p_value));
return sentry_value_new_attribute(sentry_value_new_int64((int64_t)p_value), NULL);
} break;
case Variant::FLOAT: {
sentry_value_set_by_key(obj, "type", sentry_value_new_string("double"));
sentry_value_set_by_key(obj, "value", sentry_value_new_double((double)p_value));
return sentry_value_new_attribute(sentry_value_new_double((double)p_value), NULL);
} break;
default: {
sentry_value_set_by_key(obj, "type", sentry_value_new_string("string"));
sentry_value_set_by_key(obj, "value", sentry_value_new_string(p_value.stringify().utf8()));
return sentry_value_new_attribute(sentry_value_new_string(p_value.stringify().utf8()), NULL);
} break;
}
return obj;
}

} // namespace sentry::native
52 changes: 31 additions & 21 deletions src/sentry/sentry_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,52 @@

namespace sentry {

void SentryLogger::log(LogLevel p_level, const String &p_body) {
INTERNAL_SDK()->log(p_level, p_body);
void SentryLogger::log(LogLevel p_level, const String &p_body, const Dictionary &p_params) {
String body = p_body;
Dictionary attributes;
if (!p_params.is_empty()) {
attributes["sentry.message.template"] = p_body;
for (const Variant &key : p_params.keys()) {
String attr_key = "sentry.message.parameter." + key.stringify();
attributes[attr_key] = p_params[key];
}
body = p_body.format(p_params);
}
INTERNAL_SDK()->log(p_level, body, attributes);
}

void SentryLogger::trace(const String &p_body) {
INTERNAL_SDK()->log(LOG_LEVEL_TRACE, p_body);
void SentryLogger::trace(const String &p_body, const Dictionary &p_params) {
log(LOG_LEVEL_TRACE, p_body, p_params);
}

void SentryLogger::debug(const String &p_body) {
INTERNAL_SDK()->log(LOG_LEVEL_DEBUG, p_body);
void SentryLogger::debug(const String &p_body, const Dictionary &p_params) {
log(LOG_LEVEL_DEBUG, p_body, p_params);
}

void SentryLogger::info(const String &p_body) {
INTERNAL_SDK()->log(LOG_LEVEL_INFO, p_body);
void SentryLogger::info(const String &p_body, const Dictionary &p_params) {
log(LOG_LEVEL_INFO, p_body, p_params);
}

void SentryLogger::warn(const String &p_body) {
INTERNAL_SDK()->log(LOG_LEVEL_WARN, p_body);
void SentryLogger::warn(const String &p_body, const Dictionary &p_params) {
log(LOG_LEVEL_WARN, p_body, p_params);
}

void SentryLogger::error(const String &p_body) {
INTERNAL_SDK()->log(LOG_LEVEL_ERROR, p_body);
void SentryLogger::error(const String &p_body, const Dictionary &p_params) {
log(LOG_LEVEL_ERROR, p_body, p_params);
}

void SentryLogger::fatal(const String &p_body) {
INTERNAL_SDK()->log(LOG_LEVEL_FATAL, p_body);
void SentryLogger::fatal(const String &p_body, const Dictionary &p_params) {
log(LOG_LEVEL_FATAL, p_body, p_params);
}

void SentryLogger::_bind_methods() {
ClassDB::bind_method(D_METHOD("log", "level", "body"), &SentryLogger::log);
ClassDB::bind_method(D_METHOD("trace", "body"), &SentryLogger::trace);
ClassDB::bind_method(D_METHOD("debug", "body"), &SentryLogger::debug);
ClassDB::bind_method(D_METHOD("info", "body"), &SentryLogger::info);
ClassDB::bind_method(D_METHOD("warn", "body"), &SentryLogger::warn);
ClassDB::bind_method(D_METHOD("error", "body"), &SentryLogger::error);
ClassDB::bind_method(D_METHOD("fatal", "body"), &SentryLogger::fatal);
ClassDB::bind_method(D_METHOD("log", "level", "body", "parameters"), &SentryLogger::log, DEFVAL(Dictionary()));
ClassDB::bind_method(D_METHOD("trace", "body", "parameters"), &SentryLogger::trace, DEFVAL(Dictionary()));
ClassDB::bind_method(D_METHOD("debug", "body", "parameters"), &SentryLogger::debug, DEFVAL(Dictionary()));
ClassDB::bind_method(D_METHOD("info", "body", "parameters"), &SentryLogger::info, DEFVAL(Dictionary()));
ClassDB::bind_method(D_METHOD("warn", "body", "parameters"), &SentryLogger::warn, DEFVAL(Dictionary()));
ClassDB::bind_method(D_METHOD("error", "body", "parameters"), &SentryLogger::error, DEFVAL(Dictionary()));
ClassDB::bind_method(D_METHOD("fatal", "body", "parameters"), &SentryLogger::fatal, DEFVAL(Dictionary()));
}

SentryLogger::SentryLogger() {}
Expand Down
14 changes: 7 additions & 7 deletions src/sentry/sentry_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class SentryLogger : public Object {
static void _bind_methods();

public:
void log(LogLevel p_level, const String &p_body);
void trace(const String &p_body);
void debug(const String &p_body);
void info(const String &p_body);
void warn(const String &p_body);
void error(const String &p_body);
void fatal(const String &p_body);
void log(LogLevel p_level, const String &p_body, const Dictionary &p_params);
void trace(const String &p_body, const Dictionary &p_params);
void debug(const String &p_body, const Dictionary &p_params);
void info(const String &p_body, const Dictionary &p_params);
void warn(const String &p_body, const Dictionary &p_params);
void error(const String &p_body, const Dictionary &p_params);
void fatal(const String &p_body, const Dictionary &p_params);

SentryLogger();
};
Expand Down
Loading