From 625c233f314f7e5aef0008c1cab4e49ed31570cc Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 31 Oct 2023 08:59:21 +0900 Subject: [PATCH] Add log prints for debugging The LogTracer class is added for debugging. Change-Id: Ie4e12787ff5a7a3e60b5b9b054c70dea996b6a37 Signed-off-by: Hwankyu Jhun --- tizen-cpp/app-core-cpp/app_core_base.cc | 3 ++ tizen-cpp/app-core-efl-cpp/app_core_efl_base.cc | 5 ++- tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc | 5 ++- tizen-cpp/common/log_tracer.hh | 43 +++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tizen-cpp/common/log_tracer.hh diff --git a/tizen-cpp/app-core-cpp/app_core_base.cc b/tizen-cpp/app-core-cpp/app_core_base.cc index 38c02f0..aa55b1d 100644 --- a/tizen-cpp/app-core-cpp/app_core_base.cc +++ b/tizen-cpp/app-core-cpp/app_core_base.cc @@ -55,6 +55,7 @@ #include "app-core-cpp/sigterm_handler_private.hh" #include "common/glib_private.hh" #include "common/log_private.hh" +#include "common/log_tracer.hh" extern "C" void aul_finalize(); namespace tizen_cpp { @@ -1209,6 +1210,7 @@ void AppCoreBase::Run(int argc, char** argv) { } void AppCoreBase::Init(int argc, char** argv) { + LogTracer tracer("AppCoreBase::Init()"); impl_->tid_ = 0; impl_->suspended_state_ = false; impl_->allowed_bg_ = false; @@ -1291,6 +1293,7 @@ void AppCoreBase::Init(int argc, char** argv) { } void AppCoreBase::Fini() { + LogTracer tracer("AppCoreBase::Fini()"); if (impl_->signal_handler_source_) { g_source_remove(impl_->signal_handler_source_); impl_->signal_handler_source_ = 0; diff --git a/tizen-cpp/app-core-efl-cpp/app_core_efl_base.cc b/tizen-cpp/app-core-efl-cpp/app_core_efl_base.cc index b9bc366..6260aeb 100644 --- a/tizen-cpp/app-core-efl-cpp/app_core_efl_base.cc +++ b/tizen-cpp/app-core-efl-cpp/app_core_efl_base.cc @@ -26,8 +26,9 @@ #include "app-core-efl-cpp/app_core_efl_base.hh" #include "app-core-efl-cpp/voice_elm_private.hh" -#include "common/log_private.hh" #include "common/glib_private.hh" +#include "common/log_private.hh" +#include "common/log_tracer.hh" namespace tizen_cpp { @@ -66,6 +67,7 @@ AppCoreEflBase::Impl::~Impl() { } void AppCoreEflBase::Impl::Init(int argc, char** argv) { + LogTracer tracer("AppCoreEflBase::Impl::Init()"); if (initialized_) return; @@ -118,6 +120,7 @@ void AppCoreEflBase::Impl::Init(int argc, char** argv) { } void AppCoreEflBase::Impl::Finish() { + LogTracer tracer("AppCoreEflBase::Impl::Finish()"); if (!initialized_) return; diff --git a/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc b/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc index 9b1c99f..2eeb488 100644 --- a/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc +++ b/tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc @@ -45,12 +45,14 @@ #include "common/ecore_handler.hh" #include "common/glib_private.hh" #include "common/log_private.hh" +#include "common/log_tracer.hh" namespace tizen_cpp { constexpr const char K_SERVICE_THREAD[] = "__K_SERVICE_THREAD"; constexpr const char K_HINT_RECENT_SCREEN_POSITION[] = "__K_HINT_RECENT_SCREEN_POSITION"; +const int APPID_MAX = 256; class AppCoreUiBase::Impl { public: @@ -278,6 +280,7 @@ void AppCoreUiBase::Impl::SetAppId() { } void AppCoreUiBase::Impl::PluginInit(int argc, char** argv) { + LogTracer tracer("AppCoreUiBase::Impl::PluginInit()"); plugin_.reset(AppCoreUiPlugin::Load()); if (plugin_ == nullptr) return; @@ -477,7 +480,7 @@ void AppCoreUiBase::DoRun(int argc, char** argv) { impl_->handler_->Init(); impl_->PluginInit(argc, argv); - char appid[PATH_MAX] = {0, }; + char appid[APPID_MAX] = {0, }; int ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); if (ret != 0) _E("Fail to get appid. pid(%d)", getpid()); diff --git a/tizen-cpp/common/log_tracer.hh b/tizen-cpp/common/log_tracer.hh new file mode 100644 index 0000000..6c5823b --- /dev/null +++ b/tizen-cpp/common/log_tracer.hh @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TIZEN_CPP_COMMON_LOG_TRACER_HH_ +#define TIZEN_CPP_COMMON_LOG_TRACER_HH_ + +#include +#include + +#include "common/log_private.hh" + +namespace tizen_cpp { + +class LogTracer { + public: + explicit LogTracer(std::string_view message) : message_(std::move(message)) { + _W("[BEGIN] %s", message_.data()); + } + + ~LogTracer() { + _W("[END] %s", message_.data()); + } + + private: + std::string_view message_; +}; + +} // namespace tizen_cpp + +#endif // TIZEN_CPP_COMMON_LOG_TRACER_HH_ -- 2.7.4