Skip to content

refactor: enhance logging across various components for better error tracking and debugging #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
8 changes: 4 additions & 4 deletions core/include/ten_runtime/binding/cpp/detail/addon.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class addon_t : public binding_handle_t {
try {
on_init(ten_env);
} catch (...) {
TEN_LOGW("Caught a exception of type '%s' in addon on_init().",
TEN_LOGW("Caught a exception of type '%s' in addon on_init()",
curr_exception_type_name().c_str());
}
}
Expand All @@ -86,7 +86,7 @@ class addon_t : public binding_handle_t {
try {
on_deinit(ten_env);
} catch (...) {
TEN_LOGW("Caught a exception '%s' in addon on_deinit().",
TEN_LOGW("Caught a exception '%s' in addon on_deinit()",
curr_exception_type_name().c_str());
}
}
Expand All @@ -96,7 +96,7 @@ class addon_t : public binding_handle_t {
try {
on_create_instance(ten_env, name, context);
} catch (...) {
TEN_LOGW("Caught a exception '%s' in addon on_create_instance(%s).",
TEN_LOGW("Caught a exception '%s' in addon on_create_instance(%s)",
curr_exception_type_name().c_str(), name);
}
}
Expand All @@ -106,7 +106,7 @@ class addon_t : public binding_handle_t {
try {
on_destroy_instance(ten_env, instance, context);
} catch (...) {
TEN_LOGW("Caught a exception '%s' in addon on_destroy_instance().",
TEN_LOGW("Caught a exception '%s' in addon on_destroy_instance()",
curr_exception_type_name().c_str());
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/include/ten_runtime/binding/cpp/detail/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class app_t {
try {
on_configure(ten_env);
} catch (...) {
TEN_LOGW("Caught a exception of type '%s' in App on_configure().",
TEN_LOGW("Caught a exception of type '%s' in App on_configure()",
curr_exception_type_name().c_str());
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ class app_t {
try {
on_init(ten_env);
} catch (...) {
TEN_LOGW("Caught a exception of type '%s' in App on_init().",
TEN_LOGW("Caught a exception of type '%s' in App on_init()",
curr_exception_type_name().c_str());
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ class app_t {
try {
on_deinit(ten_env);
} catch (...) {
TEN_LOGW("Caught a exception of type '%s' in App on_close().",
TEN_LOGW("Caught a exception of type '%s' in App on_close()",
curr_exception_type_name().c_str());
}
}
Expand Down
26 changes: 13 additions & 13 deletions core/include/ten_runtime/binding/cpp/detail/ten_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_uint8(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -237,7 +237,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_uint16(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -255,7 +255,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_uint32(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -273,7 +273,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_uint64(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -291,7 +291,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_int8(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -309,7 +309,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_int16(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -327,7 +327,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_int32(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -345,7 +345,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_int64(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -363,7 +363,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_float32(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -381,7 +381,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_float64(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -399,7 +399,7 @@ class ten_env_t {
error_t cpp_err;
const auto *result = ten_value_peek_raw_str(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -421,7 +421,7 @@ class ten_env_t {
error_t cpp_err;
auto *result = ten_value_get_ptr(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand All @@ -439,7 +439,7 @@ class ten_env_t {
error_t cpp_err;
auto result = ten_value_get_bool(c_value, cpp_err.get_c_error());
if (!cpp_err.is_success()) {
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
TEN_LOGW("Failed to get property %s because of incorrect type", path);
}
if (err != nullptr) {
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ten_client_proxy_internal_impl_t : public ten::extension_tester_t {
TEN_ASSERT(ten_env_tester_proxy_, "Invalid state.");

if (ten_env_tester_proxy_ == nullptr) {
TEN_LOGE("Failed to send_cmd: %s before started.",
TEN_LOGE("Failed to send_cmd: %s before started",
cmd->get_name().c_str());
return false;
}
Expand All @@ -132,7 +132,7 @@ class ten_client_proxy_internal_impl_t : public ten::extension_tester_t {
TEN_ASSERT(ten_env_tester_proxy_, "Invalid state.");

if (ten_env_tester_proxy_ == nullptr) {
TEN_LOGE("Failed to send_data before started.");
TEN_LOGE("Failed to send_data before started");
return false;
}

Expand All @@ -150,7 +150,7 @@ class ten_client_proxy_internal_impl_t : public ten::extension_tester_t {
TEN_ASSERT(ten_env_tester_proxy_, "Invalid state.");

if (ten_env_tester_proxy_ == nullptr) {
TEN_LOGE("Failed to send_audio_frame before started.");
TEN_LOGE("Failed to send_audio_frame before started");
return false;
}

Expand All @@ -169,7 +169,7 @@ class ten_client_proxy_internal_impl_t : public ten::extension_tester_t {
TEN_ASSERT(ten_env_tester_proxy_, "Invalid state.");

if (ten_env_tester_proxy_ == nullptr) {
TEN_LOGE("Failed to send_video_frame before started.");
TEN_LOGE("Failed to send_video_frame before started");
return false;
}

Expand All @@ -186,7 +186,7 @@ class ten_client_proxy_internal_impl_t : public ten::extension_tester_t {

bool stop() {
if (ten_env_tester_proxy_ == nullptr) {
TEN_LOGE("Failed to stop before started.");
TEN_LOGE("Failed to stop before started");
return false;
}

Expand Down
10 changes: 5 additions & 5 deletions core/src/ten_runtime/addon/addon.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static void ten_app_addon_loaded_using_all_addon_loaders(ten_env_t *ten_env,
manager, addon_context->addon_type,
ten_string_get_raw_str(&addon_context->addon_name), register_ctx);
if (!success) {
TEN_LOGE("Failed to load the addon %s using all addon loaders.",
TEN_LOGE("Failed to load the addon %s using all addon loaders",
ten_string_get_raw_str(&addon_context->addon_name));
ten_addon_register_ctx_destroy(register_ctx);

Expand Down Expand Up @@ -376,7 +376,7 @@ static void ten_app_create_addon_instance(ten_app_t *app,
if (addon_context->flow ==
TEN_ADDON_CONTEXT_FLOW_ENGINE_CREATE_EXTENSION_GROUP) {
if (ten_c_string_is_empty(addon_name)) {
TEN_LOGI("The addon name is empty, will not create the extension group.");
TEN_LOGI("The addon name is empty, will not create the extension group");

ten_app_notify_create_addon_instance_failed(app, addon_context);
return;
Expand All @@ -399,7 +399,7 @@ static void ten_app_create_addon_instance(ten_app_t *app,
ten_addon_store_find_by_type(app, addon_type, addon_name);
if (addon_host) {
// The addon already exists; create an instance of it.
TEN_LOGI("The addon %s already exists; create an instance of it.",
TEN_LOGI("The addon %s already exists; create an instance of it",
addon_name);
ten_addon_host_create_instance_async(addon_host, instance_name,
addon_context);
Expand Down Expand Up @@ -432,7 +432,7 @@ static void ten_app_create_addon_instance(ten_app_t *app,
return;
}

TEN_LOGD("Try to load the addon %s using all installed addon loaders.",
TEN_LOGD("Try to load the addon %s using all installed addon loaders",
addon_name);

ten_addon_try_load_specific_addon_using_all_addon_loaders(
Expand Down Expand Up @@ -510,7 +510,7 @@ ten_addon_host_t *ten_addon_register(TEN_ADDON_TYPE addon_type,
TEN_ASSERT(addon_type != TEN_ADDON_TYPE_INVALID, "Invalid argument.");

if (!addon_name || strlen(addon_name) == 0) {
TEN_LOGE("The addon name is required.");
TEN_LOGE("The addon name is required");
// NOLINTNEXTLINE(concurrency-mt-unsafe)
exit(EXIT_FAILURE);
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/ten_runtime/addon/addon_autoload.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static bool load_all_dynamic_libraries_under_path(const char *path) {
ten_string_t *short_name = NULL;

if (!path || !strlen(path)) {
TEN_LOGE("Failed to load dynamic library: invalid parameter.");
TEN_LOGE("Failed to load dynamic library: invalid parameter");
goto done;
}

Expand Down Expand Up @@ -169,7 +169,7 @@ static void ten_addon_load_from_base_dir(const char *path) {

if (!ten_path_exists(ten_string_get_raw_str(&lib_dir)) ||
!ten_path_is_dir(&lib_dir)) {
TEN_LOGD("The dynamic library path(%s) does not exist.",
TEN_LOGD("The dynamic library path(%s) does not exist",
ten_string_get_raw_str(&lib_dir));
goto done;
}
Expand Down Expand Up @@ -575,7 +575,7 @@ bool ten_addon_load_all_extensions_from_app_base_dir(
if (ten_addon_manager_is_addon_loaded(
ten_addon_manager_get_instance(), TEN_ADDON_TYPE_EXTENSION,
ten_string_get_raw_str(short_name))) {
TEN_LOGD("Addon %s:%s is already loaded, skipping.",
TEN_LOGD("Addon %s:%s is already loaded, skipping",
ten_addon_type_to_string(TEN_ADDON_TYPE_EXTENSION),
ten_string_get_raw_str(short_name));

Expand All @@ -595,13 +595,13 @@ bool ten_addon_load_all_extensions_from_app_base_dir(
ten_addon_manager_is_addon_loaded(
ten_addon_manager_get_instance(), TEN_ADDON_TYPE_EXTENSION,
ten_string_get_raw_str(short_name))) {
TEN_LOGD("Addon %s:%s is loaded successfully.",
TEN_LOGD("Addon %s:%s is loaded successfully",
ten_addon_type_to_string(TEN_ADDON_TYPE_EXTENSION),
ten_string_get_raw_str(short_name));
} else {
TEN_LOGD(
"Failed to load addon %s:%s using native addon loader, will try "
"other methods.",
"other methods",
ten_addon_type_to_string(TEN_ADDON_TYPE_EXTENSION),
ten_string_get_raw_str(short_name));

Expand Down
5 changes: 2 additions & 3 deletions core/src/ten_runtime/addon/addon_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ bool ten_addon_manager_add_addon(ten_addon_manager_t *self,
} else {
// Handle the case where the addon is already added.
// For now, log a warning.
TEN_LOGW("Addon '%s:%s' is already registered.", addon_type_str,
addon_name);
TEN_LOGW("Addon '%s:%s' is already registered", addon_type_str, addon_name);
}

ten_mutex_unlock(self->mutex);
Expand Down Expand Up @@ -239,7 +238,7 @@ bool ten_addon_manager_register_specific_addon(ten_addon_manager_t *self,
}

if (!success) {
TEN_LOGI("Unable to find '%s:%s' in registry.",
TEN_LOGI("Unable to find '%s:%s' in registry",
ten_addon_type_to_string(addon_type), addon_name);
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/ten_runtime/addon/ten_env/on_xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ void ten_addon_on_init_done(ten_env_t *self) {
bool rc = ten_handle_manifest_info_when_on_configure_done(
&addon_host->manifest_info, NULL, &addon_host->manifest, &err);
if (!rc) {
TEN_LOGW("Failed to load addon manifest data, FATAL ERROR.");
TEN_LOGW("Failed to load addon manifest data, FATAL ERROR");
// NOLINTNEXTLINE(concurrency-mt-unsafe)
exit(EXIT_FAILURE);
}

rc = ten_handle_property_info_when_on_configure_done(
&addon_host->property_info, NULL, &addon_host->property, &err);
if (!rc) {
TEN_LOGW("Failed to load addon property data, FATAL ERROR.");
TEN_LOGW("Failed to load addon property data, FATAL ERROR");
// NOLINTNEXTLINE(concurrency-mt-unsafe)
exit(EXIT_FAILURE);
}
Expand All @@ -77,7 +77,7 @@ void ten_addon_on_init_done(ten_env_t *self) {
!ten_string_is_equal_c_str(&addon_host->name, manifest_name)) {
TEN_LOGW(
"The registered extension name (%s) is not equal to the name (%s) in "
"the manifest.",
"the manifest",
ten_string_get_raw_str(&addon_host->name), manifest_name);

// Get 'name' from manifest, and check the consistency between the name
Expand Down
6 changes: 3 additions & 3 deletions core/src/ten_runtime/addon_loader/addon_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static void ten_addon_loader_init_done(ten_env_t *ten_env, void *cb_data) {
ten_app_thread_on_addon_loader_init_done,
app, on_addon_loader_init_done_ctx);
if (rc) {
TEN_LOGE("Failed to post task to app runloop.");
TEN_LOGE("Failed to post task to app runloop");
TEN_ASSERT(0, "Should not happen.");
}
}
Expand Down Expand Up @@ -414,7 +414,7 @@ void ten_addon_loader_addons_create_singleton_instance(
&err);

if (!res) {
TEN_LOGE("Failed to create addon_loader instance %s, %s.",
TEN_LOGE("Failed to create addon_loader instance %s, %s",
ten_string_get_raw_str(&loader_addon_host->name),
ten_error_message(&err));
#if defined(_DEBUG)
Expand Down Expand Up @@ -473,7 +473,7 @@ static void ten_addon_loader_deinit_done(ten_env_t *ten_env, void *cb_data) {
ten_app_thread_on_addon_loader_deinit_done,
app, on_addon_loader_deinit_done_ctx);
if (rc) {
TEN_LOGE("Failed to post task to app runloop.");
TEN_LOGE("Failed to post task to app runloop");
TEN_ASSERT(0, "Should not happen.");
}
}
Expand Down
Loading
Loading