Add log prints for debugging 53/300653/2
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 30 Oct 2023 23:59:21 +0000 (08:59 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 31 Oct 2023 00:13:01 +0000 (09:13 +0900)
The LogTracer class is added for debugging.

Change-Id: Ie4e12787ff5a7a3e60b5b9b054c70dea996b6a37
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
tizen-cpp/app-core-cpp/app_core_base.cc
tizen-cpp/app-core-efl-cpp/app_core_efl_base.cc
tizen-cpp/app-core-ui-cpp/app_core_ui_base.cc
tizen-cpp/common/log_tracer.hh [new file with mode: 0644]

index 38c02f0..aa55b1d 100644 (file)
@@ -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;
index b9bc366..6260aeb 100644 (file)
@@ -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;
 
index 9b1c99f..2eeb488 100644 (file)
 #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 (file)
index 0000000..6c5823b
--- /dev/null
@@ -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 <string_view>
+#include <utility>
+
+#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_