8a2a150c6e2b442441a79bae4dfda0f73b1b2df3
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / combined-update-render-controller-debug.h
1 #ifndef DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_DEBUG_H
2 #define DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_DEBUG_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/integration-api/trace.h>
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 namespace Adaptor
30 {
31 namespace
32 {
33 // Uncomment next line for FULL logging of the ThreadSynchronization class in release mode
34 //#define RELEASE_BUILD_LOGGING
35
36 #ifdef DEBUG_ENABLED
37
38 #define ENABLE_LOG_IN_COLOR
39 #define ENABLE_COUNTER_LOGGING
40 #define ENABLE_UPDATE_RENDER_THREAD_LOGGING
41 #define ENABLE_EVENT_LOGGING
42
43 #define DEBUG_LEVEL_COUNTER Debug::Verbose
44 #define DEBUG_LEVEL_UPDATE_RENDER Debug::General
45 #define DEBUG_LEVEL_EVENT Debug::Concise
46
47 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_THREAD_SYNC");
48
49 #define LOG_THREAD_SYNC(level, color, format, ...) \
50   DALI_LOG_INFO(gLogFilter, level, "%s" format "%s\n", color, ##__VA_ARGS__, COLOR_CLEAR)
51
52 #define LOG_THREAD_SYNC_TRACE(color)                                                                      \
53   Dali::Integration::Log::TraceObj debugTraceObj(gLogFilter, "%s%s%s", color, __FUNCTION__, COLOR_CLEAR); \
54   if(!gLogFilter->IsTraceEnabled())                                                                       \
55   {                                                                                                       \
56     LOG_THREAD_SYNC(Debug::Concise, color, "%s", __FUNCTION__);                                           \
57   }
58
59 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...)                                                                                \
60   Dali::Integration::Log::TraceObj debugTraceObj(gLogFilter, "%s%s: " format "%s", color, __FUNCTION__, ##__VA_ARGS__, COLOR_CLEAR); \
61   if(!gLogFilter->IsTraceEnabled())                                                                                                  \
62   {                                                                                                                                  \
63     LOG_THREAD_SYNC(Debug::Concise, color, "%s: " format, __FUNCTION__, ##__VA_ARGS__);                                              \
64   }
65
66 #elif defined(RELEASE_BUILD_LOGGING)
67
68 #define ENABLE_LOG_IN_COLOR
69 #define ENABLE_COUNTER_LOGGING
70 #define ENABLE_UPDATE_RENDER_THREAD_LOGGING
71 #define ENABLE_EVENT_LOGGING
72
73 #define DEBUG_LEVEL_COUNTER 0
74 #define DEBUG_LEVEL_UPDATE_RENDER 0
75 #define DEBUG_LEVEL_EVENT 0
76
77 #define LOG_THREAD_SYNC(level, color, format, ...) \
78   Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s" format "%s\n", color, ##__VA_ARGS__, COLOR_CLEAR)
79
80 #define LOG_THREAD_SYNC_TRACE(color) \
81   Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s%s%s\n", color, __FUNCTION__, COLOR_CLEAR)
82
83 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...) \
84   Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s%s: " format "%s\n", color, __FUNCTION__, ##__VA_ARGS__, COLOR_CLEAR)
85
86 #else
87
88 #define LOG_THREAD_SYNC(level, color, format, ...)
89 #define LOG_THREAD_SYNC_TRACE(color)
90 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...)
91
92 #endif // DEBUG_ENABLED
93
94 #ifdef ENABLE_LOG_IN_COLOR
95 #define COLOR_YELLOW "\033[33m"
96 #define COLOR_LIGHT_RED "\033[91m"
97 #define COLOR_LIGHT_YELLOW "\033[93m"
98 #define COLOR_WHITE "\033[97m"
99 #define COLOR_CLEAR "\033[0m"
100 #else
101 #define COLOR_YELLOW
102 #define COLOR_LIGHT_RED
103 #define COLOR_LIGHT_YELLOW
104 #define COLOR_WHITE
105 #define COLOR_CLEAR
106 #endif
107
108 #ifdef ENABLE_COUNTER_LOGGING
109 #define LOG_COUNTER_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_RED, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
110 #define LOG_COUNTER_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_YELLOW, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
111 #else
112 #define LOG_COUNTER_EVENT(format, ...)
113 #define LOG_COUNTER_UPDATE_RENDER(format, ...)
114 #endif
115
116 #ifdef ENABLE_UPDATE_RENDER_THREAD_LOGGING
117 #define LOG_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_UPDATE_RENDER, COLOR_YELLOW, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
118 #define LOG_UPDATE_RENDER_TRACE LOG_THREAD_SYNC_TRACE(COLOR_YELLOW)
119 #define LOG_UPDATE_RENDER_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_YELLOW, format, ##__VA_ARGS__)
120 #else
121 #define LOG_UPDATE_RENDER(format, ...)
122 #define LOG_UPDATE_RENDER_TRACE
123 #define LOG_UPDATE_RENDER_TRACE_FMT(format, ...)
124 #endif
125
126 #ifdef ENABLE_EVENT_LOGGING
127 #define LOG_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_EVENT, COLOR_WHITE, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
128 #define LOG_EVENT_TRACE LOG_THREAD_SYNC_TRACE(COLOR_WHITE)
129 #define LOG_EVENT_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_WHITE, format, ##__VA_ARGS__)
130 #else
131 #define LOG_EVENT(format, ...)
132 #define LOG_EVENT_TRACE
133 #define LOG_EVENT_TRACE_FMT(format, ...)
134 #endif
135
136 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_COMBINED, false);
137 #define TRACE_UPDATE_RENDER_BEGIN(tag) DALI_TRACE_BEGIN(gTraceFilter, tag)
138 #define TRACE_UPDATE_RENDER_END(tag) DALI_TRACE_END(gTraceFilter, tag)
139
140 } // unnamed namespace
141
142 } // namespace Adaptor
143
144 } // namespace Internal
145
146 } // namespace Dali
147
148 #endif // DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_DEBUG_H