Appendix log for ttrace + Print keycode and timestamp
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 24 May 2023 00:32:05 +0000 (09:32 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Wed, 31 May 2023 04:40:01 +0000 (13:40 +0900)
Since we need to know the state of key event and timestamp, let we print it
only if performance check state enabled

And also, we need to print the additional informations in same line.
(Since third-party performance profile tools requirements)

Change-Id: I9b1b176fcba76e5997b09136b2d634ad493dcf5f
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/dali-test-suite-utils/test-application.h
dali/integration-api/trace.cpp
dali/integration-api/trace.h
dali/internal/event/events/key-event-processor.cpp

index e4c6078..a8354e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * 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.
@@ -99,15 +99,15 @@ TestApplication::~TestApplication()
   delete mCore;
 }
 
-void TestApplication::LogContext(bool start, const char* tag)
+void TestApplication::LogContext(bool start, const char* tag, const char* message)
 {
   if(start)
   {
-    fprintf(stderr, "INFO: Trace Start: %s\n", tag);
+    fprintf(stderr, "INFO: Trace Start: %s %s\n", tag, message ? message : "");
   }
   else
   {
-    fprintf(stderr, "INFO: Trace End: %s\n", tag);
+    fprintf(stderr, "INFO: Trace End: %s %s\n", tag, message ? message : "");
   }
 }
 
index 1b101c5..ce0e151 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_APPLICATION_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * 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.
@@ -60,7 +60,7 @@ public:
   void InitializeCore();
   ~TestApplication() override;
   static void              LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
-  static void              LogContext(bool start, const char* tag);
+  static void              LogContext(bool start, const char* tag, const char* message);
   Dali::Integration::Core& GetCore();
   TestPlatformAbstraction& GetPlatform();
   TestRenderController&    GetRenderController();
index 704e66f..5786f3a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * 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.
@@ -35,13 +35,13 @@ void InstallLogContextFunction(const LogContextFunction& logContextFunction)
   gThreadLocalLogContextFunction = logContextFunction;
 }
 
-void LogContext(bool start, const char* tag)
+void LogContext(bool start, const char* tag, const char* message)
 {
   if(!gThreadLocalLogContextFunction)
   {
     return;
   }
-  gThreadLocalLogContextFunction(start, tag);
+  gThreadLocalLogContextFunction(start, tag, message);
 }
 
 #ifdef TRACE_ENABLED
@@ -109,7 +109,12 @@ void Filter::DisableGlobalTrace()
  */
 void Filter::BeginTrace(const char* tagName)
 {
-  Dali::Integration::Trace::LogContext(true, tagName);
+  Dali::Integration::Trace::LogContext(true, tagName, nullptr);
+}
+
+void Filter::BeginTrace(const char* tagName, const char* message)
+{
+  Dali::Integration::Trace::LogContext(true, tagName, message);
 }
 
 /**
@@ -117,7 +122,12 @@ void Filter::BeginTrace(const char* tagName)
  */
 void Filter::EndTrace(const char* tagName)
 {
-  Dali::Integration::Trace::LogContext(false, tagName);
+  Dali::Integration::Trace::LogContext(false, tagName, nullptr);
+}
+
+void Filter::EndTrace(const char* tagName, const char* message)
+{
+  Dali::Integration::Trace::LogContext(false, tagName, message);
 }
 
 /**
index b0ad6d8..794d839 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTEGRATION_TRACE_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * 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.
@@ -32,15 +32,16 @@ namespace Trace
 {
 /**
  * Used by tracing macros to log a context message
- * @param start a bool to indicate start (true) or end (false) of the tracing / logging
- * @param tag a unique event tag name
+ * @param[in] start a bool to indicate start (true) or end (false) of the tracing / logging
+ * @param[in] tag a unique event tag name
+ * @param[in] message an additional message for this trace. Ignore if it is nullptr
  */
-DALI_CORE_API void LogContext(bool start, const char* tag);
+DALI_CORE_API void LogContext(bool start, const char* tag, const char* message = nullptr);
 
 /**
  * typedef for the LogContextFunction function.
  */
-using LogContextFunction = void (*)(bool, const char*);
+using LogContextFunction = void (*)(bool, const char*, const char*);
 
 /**
  * A LogContextFunction function has to be installed for every thread that wants to use tracing.
@@ -118,12 +119,26 @@ public:
   void BeginTrace(const char* tagName);
 
   /**
+   * Begin trace.
+   * @param[in] tagName - a unique event tag name.
+   * @param[in] message - an additional message for this trace if needs.
+   */
+  void BeginTrace(const char* tagName, const char* message);
+
+  /**
    * End trace.
    * @param[in] tagName - a unique event tag name.
    */
   void EndTrace(const char* tagName);
 
   /**
+   * End trace.
+   * @param[in] tagName - a unique event tag name.
+   * @param[in] message - an additional message for this trace if needs.
+   */
+  void EndTrace(const char* tagName, const char* message);
+
+  /**
    * Enable trace on all filters.
    */
   static void EnableGlobalTrace();
@@ -198,6 +213,12 @@ public:
     filter->BeginTrace(tag);             \
   }
 
+#define DALI_TRACE_BEGIN_WITH_MESSAGE(filter, tag, message) \
+  if(filter && filter->IsTraceEnabled())                    \
+  {                                                         \
+    filter->BeginTrace(tag, message);                       \
+  }
+
 /**
  * End of tracing
  */
@@ -207,6 +228,12 @@ public:
     filter->EndTrace(tag);               \
   }
 
+#define DALI_TRACE_END_WITH_MESSAGE(filter, tag, message) \
+  if(filter && filter->IsTraceEnabled())                  \
+  {                                                       \
+    filter->EndTrace(tag, message);                       \
+  }
+
 /**
  * Used for function tracing. It logs tracing of the fuction from start to end.
  */
@@ -223,7 +250,9 @@ public:
 
 #define DALI_INIT_TRACE_FILTER(name, tag, enable)
 #define DALI_TRACE_BEGIN(filter, tag)
+#define DALI_TRACE_BEGIN_WITH_MESSAGE(filter, tag, message)
 #define DALI_TRACE_END(filter, tag)
+#define DALI_TRACE_END_WITH_MESSAGE(filter, tag, message)
 #define DALI_TRACE_FUNCTION(filter)
 #define DALI_TRACE_SCOPE(filter, tag)
 
index 60fee2e..d454e5c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * 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.
 // CLASS HEADER
 #include <dali/internal/event/events/key-event-processor.h>
 
+// EXTERNAL INCLUDES
+#ifdef TRACE_ENABLED
+#include <sstream> ///< for std::ostringstream
+#endif
+
 // INTERNAL INCLUDES
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/trace.h>
@@ -32,6 +37,14 @@ namespace Internal
 namespace
 {
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
+
+#ifdef TRACE_ENABLED
+const char* KEY_EVENT_STATES[Dali::KeyEvent::State::UP + 1] =
+  {
+    "DOWN",
+    "UP",
+};
+#endif
 } // namespace
 
 KeyEventProcessor::KeyEventProcessor(Scene& scene)
@@ -46,7 +59,14 @@ void KeyEventProcessor::ProcessKeyEvent(const Integration::KeyEvent& event)
   KeyEventPtr    keyEvent(new KeyEvent(event.keyName, event.logicalKey, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast<Dali::KeyEvent::State>(event.state), event.compose, event.deviceName, event.deviceClass, event.deviceSubclass));
   Dali::KeyEvent keyEventHandle(keyEvent.Get());
 
-  DALI_TRACE_SCOPE(gTraceFilter, "DALI_PROCESS_KEY_EVENT");
+#ifdef TRACE_ENABLED
+  if(gTraceFilter && gTraceFilter->IsTraceEnabled())
+  {
+    std::ostringstream stream;
+    stream << "[name:" << event.keyName << ", code:" << event.keyCode << ", state:" << KEY_EVENT_STATES[event.state] << ", time:" << event.time << "]";
+    DALI_TRACE_BEGIN_WITH_MESSAGE(gTraceFilter, "DALI_PROCESS_KEY_EVENT", stream.str().c_str());
+  }
+#endif
 
   // Emit the key event signal from the scene.
   bool consumed = mScene.EmitInterceptKeyEventSignal(keyEventHandle);
@@ -58,6 +78,12 @@ void KeyEventProcessor::ProcessKeyEvent(const Integration::KeyEvent& event)
   {
     mScene.EmitKeyEventSignal(keyEventHandle);
   }
+#ifdef TRACE_ENABLED
+  if(gTraceFilter && gTraceFilter->IsTraceEnabled())
+  {
+    DALI_TRACE_END(gTraceFilter, "DALI_PROCESS_KEY_EVENT");
+  }
+#endif
 }
 
 } // namespace Internal