Skip to content

Commit 23ccce8

Browse files
authored
refactor: enhance logging across various components for better error tracking and debugging (#775)
1 parent cf05791 commit 23ccce8

File tree

117 files changed

+532
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+532
-427
lines changed

core/include/ten_runtime/binding/cpp/detail/addon.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class addon_t : public binding_handle_t {
7777
try {
7878
on_init(ten_env);
7979
} catch (...) {
80-
TEN_LOGW("Caught a exception of type '%s' in addon on_init().",
80+
TEN_LOGW("Caught a exception of type '%s' in addon on_init()",
8181
curr_exception_type_name().c_str());
8282
}
8383
}
@@ -86,7 +86,7 @@ class addon_t : public binding_handle_t {
8686
try {
8787
on_deinit(ten_env);
8888
} catch (...) {
89-
TEN_LOGW("Caught a exception '%s' in addon on_deinit().",
89+
TEN_LOGW("Caught a exception '%s' in addon on_deinit()",
9090
curr_exception_type_name().c_str());
9191
}
9292
}
@@ -96,7 +96,7 @@ class addon_t : public binding_handle_t {
9696
try {
9797
on_create_instance(ten_env, name, context);
9898
} catch (...) {
99-
TEN_LOGW("Caught a exception '%s' in addon on_create_instance(%s).",
99+
TEN_LOGW("Caught a exception '%s' in addon on_create_instance(%s)",
100100
curr_exception_type_name().c_str(), name);
101101
}
102102
}
@@ -106,7 +106,7 @@ class addon_t : public binding_handle_t {
106106
try {
107107
on_destroy_instance(ten_env, instance, context);
108108
} catch (...) {
109-
TEN_LOGW("Caught a exception '%s' in addon on_destroy_instance().",
109+
TEN_LOGW("Caught a exception '%s' in addon on_destroy_instance()",
110110
curr_exception_type_name().c_str());
111111
}
112112
}

core/include/ten_runtime/binding/cpp/detail/app.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class app_t {
103103
try {
104104
on_configure(ten_env);
105105
} catch (...) {
106-
TEN_LOGW("Caught a exception of type '%s' in App on_configure().",
106+
TEN_LOGW("Caught a exception of type '%s' in App on_configure()",
107107
curr_exception_type_name().c_str());
108108
}
109109
}
@@ -138,7 +138,7 @@ class app_t {
138138
try {
139139
on_init(ten_env);
140140
} catch (...) {
141-
TEN_LOGW("Caught a exception of type '%s' in App on_init().",
141+
TEN_LOGW("Caught a exception of type '%s' in App on_init()",
142142
curr_exception_type_name().c_str());
143143
}
144144
}
@@ -174,7 +174,7 @@ class app_t {
174174
try {
175175
on_deinit(ten_env);
176176
} catch (...) {
177-
TEN_LOGW("Caught a exception of type '%s' in App on_close().",
177+
TEN_LOGW("Caught a exception of type '%s' in App on_close()",
178178
curr_exception_type_name().c_str());
179179
}
180180
}

core/include/ten_runtime/binding/cpp/detail/ten_env.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class ten_env_t {
219219
error_t cpp_err;
220220
auto result = ten_value_get_uint8(c_value, cpp_err.get_c_error());
221221
if (!cpp_err.is_success()) {
222-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
222+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
223223
}
224224
if (err != nullptr) {
225225
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -237,7 +237,7 @@ class ten_env_t {
237237
error_t cpp_err;
238238
auto result = ten_value_get_uint16(c_value, cpp_err.get_c_error());
239239
if (!cpp_err.is_success()) {
240-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
240+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
241241
}
242242
if (err != nullptr) {
243243
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -255,7 +255,7 @@ class ten_env_t {
255255
error_t cpp_err;
256256
auto result = ten_value_get_uint32(c_value, cpp_err.get_c_error());
257257
if (!cpp_err.is_success()) {
258-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
258+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
259259
}
260260
if (err != nullptr) {
261261
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -273,7 +273,7 @@ class ten_env_t {
273273
error_t cpp_err;
274274
auto result = ten_value_get_uint64(c_value, cpp_err.get_c_error());
275275
if (!cpp_err.is_success()) {
276-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
276+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
277277
}
278278
if (err != nullptr) {
279279
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -291,7 +291,7 @@ class ten_env_t {
291291
error_t cpp_err;
292292
auto result = ten_value_get_int8(c_value, cpp_err.get_c_error());
293293
if (!cpp_err.is_success()) {
294-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
294+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
295295
}
296296
if (err != nullptr) {
297297
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -309,7 +309,7 @@ class ten_env_t {
309309
error_t cpp_err;
310310
auto result = ten_value_get_int16(c_value, cpp_err.get_c_error());
311311
if (!cpp_err.is_success()) {
312-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
312+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
313313
}
314314
if (err != nullptr) {
315315
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -327,7 +327,7 @@ class ten_env_t {
327327
error_t cpp_err;
328328
auto result = ten_value_get_int32(c_value, cpp_err.get_c_error());
329329
if (!cpp_err.is_success()) {
330-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
330+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
331331
}
332332
if (err != nullptr) {
333333
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -345,7 +345,7 @@ class ten_env_t {
345345
error_t cpp_err;
346346
auto result = ten_value_get_int64(c_value, cpp_err.get_c_error());
347347
if (!cpp_err.is_success()) {
348-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
348+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
349349
}
350350
if (err != nullptr) {
351351
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -363,7 +363,7 @@ class ten_env_t {
363363
error_t cpp_err;
364364
auto result = ten_value_get_float32(c_value, cpp_err.get_c_error());
365365
if (!cpp_err.is_success()) {
366-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
366+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
367367
}
368368
if (err != nullptr) {
369369
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -381,7 +381,7 @@ class ten_env_t {
381381
error_t cpp_err;
382382
auto result = ten_value_get_float64(c_value, cpp_err.get_c_error());
383383
if (!cpp_err.is_success()) {
384-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
384+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
385385
}
386386
if (err != nullptr) {
387387
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -399,7 +399,7 @@ class ten_env_t {
399399
error_t cpp_err;
400400
const auto *result = ten_value_peek_raw_str(c_value, cpp_err.get_c_error());
401401
if (!cpp_err.is_success()) {
402-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
402+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
403403
}
404404
if (err != nullptr) {
405405
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -421,7 +421,7 @@ class ten_env_t {
421421
error_t cpp_err;
422422
auto *result = ten_value_get_ptr(c_value, cpp_err.get_c_error());
423423
if (!cpp_err.is_success()) {
424-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
424+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
425425
}
426426
if (err != nullptr) {
427427
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());
@@ -439,7 +439,7 @@ class ten_env_t {
439439
error_t cpp_err;
440440
auto result = ten_value_get_bool(c_value, cpp_err.get_c_error());
441441
if (!cpp_err.is_success()) {
442-
TEN_LOGW("Failed to get property %s because of incorrect type.", path);
442+
TEN_LOGW("Failed to get property %s because of incorrect type", path);
443443
}
444444
if (err != nullptr) {
445445
ten_error_copy(err->get_c_error(), cpp_err.get_c_error());

core/include/ten_runtime/binding/cpp/experimental/ten_client_proxy.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ten_client_proxy_internal_impl_t : public ten::extension_tester_t {
107107
TEN_ASSERT(ten_env_tester_proxy_, "Invalid state.");
108108

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

134134
if (ten_env_tester_proxy_ == nullptr) {
135-
TEN_LOGE("Failed to send_data before started.");
135+
TEN_LOGE("Failed to send_data before started");
136136
return false;
137137
}
138138

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

152152
if (ten_env_tester_proxy_ == nullptr) {
153-
TEN_LOGE("Failed to send_audio_frame before started.");
153+
TEN_LOGE("Failed to send_audio_frame before started");
154154
return false;
155155
}
156156

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

171171
if (ten_env_tester_proxy_ == nullptr) {
172-
TEN_LOGE("Failed to send_video_frame before started.");
172+
TEN_LOGE("Failed to send_video_frame before started");
173173
return false;
174174
}
175175

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

187187
bool stop() {
188188
if (ten_env_tester_proxy_ == nullptr) {
189-
TEN_LOGE("Failed to stop before started.");
189+
TEN_LOGE("Failed to stop before started");
190190
return false;
191191
}
192192

core/src/ten_runtime/addon/addon.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static void ten_app_addon_loaded_using_all_addon_loaders(ten_env_t *ten_env,
331331
manager, addon_context->addon_type,
332332
ten_string_get_raw_str(&addon_context->addon_name), register_ctx);
333333
if (!success) {
334-
TEN_LOGE("Failed to load the addon %s using all addon loaders.",
334+
TEN_LOGE("Failed to load the addon %s using all addon loaders",
335335
ten_string_get_raw_str(&addon_context->addon_name));
336336
ten_addon_register_ctx_destroy(register_ctx);
337337

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

381381
ten_app_notify_create_addon_instance_failed(app, addon_context);
382382
return;
@@ -399,7 +399,7 @@ static void ten_app_create_addon_instance(ten_app_t *app,
399399
ten_addon_store_find_by_type(app, addon_type, addon_name);
400400
if (addon_host) {
401401
// The addon already exists; create an instance of it.
402-
TEN_LOGI("The addon %s already exists; create an instance of it.",
402+
TEN_LOGI("The addon %s already exists; create an instance of it",
403403
addon_name);
404404
ten_addon_host_create_instance_async(addon_host, instance_name,
405405
addon_context);
@@ -432,7 +432,7 @@ static void ten_app_create_addon_instance(ten_app_t *app,
432432
return;
433433
}
434434

435-
TEN_LOGD("Try to load the addon %s using all installed addon loaders.",
435+
TEN_LOGD("Try to load the addon %s using all installed addon loaders",
436436
addon_name);
437437

438438
ten_addon_try_load_specific_addon_using_all_addon_loaders(
@@ -510,7 +510,7 @@ ten_addon_host_t *ten_addon_register(TEN_ADDON_TYPE addon_type,
510510
TEN_ASSERT(addon_type != TEN_ADDON_TYPE_INVALID, "Invalid argument.");
511511

512512
if (!addon_name || strlen(addon_name) == 0) {
513-
TEN_LOGE("The addon name is required.");
513+
TEN_LOGE("The addon name is required");
514514
// NOLINTNEXTLINE(concurrency-mt-unsafe)
515515
exit(EXIT_FAILURE);
516516
}

core/src/ten_runtime/addon/addon_autoload.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static bool load_all_dynamic_libraries_under_path(const char *path) {
8383
ten_string_t *short_name = NULL;
8484

8585
if (!path || !strlen(path)) {
86-
TEN_LOGE("Failed to load dynamic library: invalid parameter.");
86+
TEN_LOGE("Failed to load dynamic library: invalid parameter");
8787
goto done;
8888
}
8989

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

170170
if (!ten_path_exists(ten_string_get_raw_str(&lib_dir)) ||
171171
!ten_path_is_dir(&lib_dir)) {
172-
TEN_LOGD("The dynamic library path(%s) does not exist.",
172+
TEN_LOGD("The dynamic library path(%s) does not exist",
173173
ten_string_get_raw_str(&lib_dir));
174174
goto done;
175175
}
@@ -575,7 +575,7 @@ bool ten_addon_load_all_extensions_from_app_base_dir(
575575
if (ten_addon_manager_is_addon_loaded(
576576
ten_addon_manager_get_instance(), TEN_ADDON_TYPE_EXTENSION,
577577
ten_string_get_raw_str(short_name))) {
578-
TEN_LOGD("Addon %s:%s is already loaded, skipping.",
578+
TEN_LOGD("Addon %s:%s is already loaded, skipping",
579579
ten_addon_type_to_string(TEN_ADDON_TYPE_EXTENSION),
580580
ten_string_get_raw_str(short_name));
581581

@@ -595,13 +595,13 @@ bool ten_addon_load_all_extensions_from_app_base_dir(
595595
ten_addon_manager_is_addon_loaded(
596596
ten_addon_manager_get_instance(), TEN_ADDON_TYPE_EXTENSION,
597597
ten_string_get_raw_str(short_name))) {
598-
TEN_LOGD("Addon %s:%s is loaded successfully.",
598+
TEN_LOGD("Addon %s:%s is loaded successfully",
599599
ten_addon_type_to_string(TEN_ADDON_TYPE_EXTENSION),
600600
ten_string_get_raw_str(short_name));
601601
} else {
602602
TEN_LOGD(
603603
"Failed to load addon %s:%s using native addon loader, will try "
604-
"other methods.",
604+
"other methods",
605605
ten_addon_type_to_string(TEN_ADDON_TYPE_EXTENSION),
606606
ten_string_get_raw_str(short_name));
607607

core/src/ten_runtime/addon/addon_manager.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ bool ten_addon_manager_add_addon(ten_addon_manager_t *self,
112112
} else {
113113
// Handle the case where the addon is already added.
114114
// For now, log a warning.
115-
TEN_LOGW("Addon '%s:%s' is already registered.", addon_type_str,
116-
addon_name);
115+
TEN_LOGW("Addon '%s:%s' is already registered", addon_type_str, addon_name);
117116
}
118117

119118
ten_mutex_unlock(self->mutex);
@@ -239,7 +238,7 @@ bool ten_addon_manager_register_specific_addon(ten_addon_manager_t *self,
239238
}
240239

241240
if (!success) {
242-
TEN_LOGI("Unable to find '%s:%s' in registry.",
241+
TEN_LOGI("Unable to find '%s:%s' in registry",
243242
ten_addon_type_to_string(addon_type), addon_name);
244243
}
245244

core/src/ten_runtime/addon/ten_env/on_xxx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ void ten_addon_on_init_done(ten_env_t *self) {
4747
bool rc = ten_handle_manifest_info_when_on_configure_done(
4848
&addon_host->manifest_info, NULL, &addon_host->manifest, &err);
4949
if (!rc) {
50-
TEN_LOGW("Failed to load addon manifest data, FATAL ERROR.");
50+
TEN_LOGW("Failed to load addon manifest data, FATAL ERROR");
5151
// NOLINTNEXTLINE(concurrency-mt-unsafe)
5252
exit(EXIT_FAILURE);
5353
}
5454

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

8383
// Get 'name' from manifest, and check the consistency between the name

core/src/ten_runtime/addon_loader/addon_loader.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static void ten_addon_loader_init_done(ten_env_t *ten_env, void *cb_data) {
309309
ten_app_thread_on_addon_loader_init_done,
310310
app, on_addon_loader_init_done_ctx);
311311
if (rc) {
312-
TEN_LOGE("Failed to post task to app runloop.");
312+
TEN_LOGE("Failed to post task to app runloop");
313313
TEN_ASSERT(0, "Should not happen.");
314314
}
315315
}
@@ -414,7 +414,7 @@ void ten_addon_loader_addons_create_singleton_instance(
414414
&err);
415415

416416
if (!res) {
417-
TEN_LOGE("Failed to create addon_loader instance %s, %s.",
417+
TEN_LOGE("Failed to create addon_loader instance %s, %s",
418418
ten_string_get_raw_str(&loader_addon_host->name),
419419
ten_error_message(&err));
420420
#if defined(_DEBUG)
@@ -473,7 +473,7 @@ static void ten_addon_loader_deinit_done(ten_env_t *ten_env, void *cb_data) {
473473
ten_app_thread_on_addon_loader_deinit_done,
474474
app, on_addon_loader_deinit_done_ctx);
475475
if (rc) {
476-
TEN_LOGE("Failed to post task to app runloop.");
476+
TEN_LOGE("Failed to post task to app runloop");
477477
TEN_ASSERT(0, "Should not happen.");
478478
}
479479
}

0 commit comments

Comments
 (0)