2ebebb666a0a611b5b0efd264e4dfda52ad1d4bd
[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) 2021 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
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Adaptor
29 {
30 namespace
31 {
32 // Uncomment next line for FULL logging of the ThreadSynchronization class in release mode
33 //#define RELEASE_BUILD_LOGGING
34
35 #ifdef DEBUG_ENABLED
36
37 #define ENABLE_LOG_IN_COLOR
38 #define ENABLE_COUNTER_LOGGING
39 #define ENABLE_UPDATE_RENDER_THREAD_LOGGING
40 #define ENABLE_EVENT_LOGGING
41
42 #define DEBUG_LEVEL_COUNTER Debug::Verbose
43 #define DEBUG_LEVEL_UPDATE_RENDER Debug::General
44 #define DEBUG_LEVEL_EVENT Debug::Concise
45
46 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_THREAD_SYNC");
47
48 #define LOG_THREAD_SYNC(level, color, format, ...) \
49   DALI_LOG_INFO(gLogFilter, level, "%s" format "%s\n", color, ##__VA_ARGS__, COLOR_CLEAR)
50
51 #define LOG_THREAD_SYNC_TRACE(color)                                                                      \
52   Dali::Integration::Log::TraceObj debugTraceObj(gLogFilter, "%s%s%s", color, __FUNCTION__, COLOR_CLEAR); \
53   if(!gLogFilter->IsTraceEnabled())                                                                       \
54   {                                                                                                       \
55     LOG_THREAD_SYNC(Debug::Concise, color, "%s", __FUNCTION__);                                           \
56   }
57
58 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...)                                                                                \
59   Dali::Integration::Log::TraceObj debugTraceObj(gLogFilter, "%s%s: " format "%s", color, __FUNCTION__, ##__VA_ARGS__, COLOR_CLEAR); \
60   if(!gLogFilter->IsTraceEnabled())                                                                                                  \
61   {                                                                                                                                  \
62     LOG_THREAD_SYNC(Debug::Concise, color, "%s: " format, __FUNCTION__, ##__VA_ARGS__);                                              \
63   }
64
65 #elif defined(RELEASE_BUILD_LOGGING)
66
67 #define ENABLE_LOG_IN_COLOR
68 #define ENABLE_COUNTER_LOGGING
69 #define ENABLE_UPDATE_RENDER_THREAD_LOGGING
70 #define ENABLE_EVENT_LOGGING
71
72 #define DEBUG_LEVEL_COUNTER 0
73 #define DEBUG_LEVEL_UPDATE_RENDER 0
74 #define DEBUG_LEVEL_EVENT 0
75
76 #define LOG_THREAD_SYNC(level, color, format, ...) \
77   Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s" format "%s\n", color, ##__VA_ARGS__, COLOR_CLEAR)
78
79 #define LOG_THREAD_SYNC_TRACE(color) \
80   Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s%s%s\n", color, __FUNCTION__, COLOR_CLEAR)
81
82 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...) \
83   Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s%s: " format "%s\n", color, __FUNCTION__, ##__VA_ARGS__, COLOR_CLEAR)
84
85 #else
86
87 #define LOG_THREAD_SYNC(level, color, format, ...)
88 #define LOG_THREAD_SYNC_TRACE(color)
89 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...)
90
91 #endif // DEBUG_ENABLED
92
93 #ifdef ENABLE_LOG_IN_COLOR
94 #define COLOR_YELLOW "\033[33m"
95 #define COLOR_LIGHT_RED "\033[91m"
96 #define COLOR_LIGHT_YELLOW "\033[93m"
97 #define COLOR_WHITE "\033[97m"
98 #define COLOR_CLEAR "\033[0m"
99 #else
100 #define COLOR_YELLOW
101 #define COLOR_LIGHT_RED
102 #define COLOR_LIGHT_YELLOW
103 #define COLOR_WHITE
104 #define COLOR_CLEAR
105 #endif
106
107 #ifdef ENABLE_COUNTER_LOGGING
108 #define LOG_COUNTER_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_RED, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
109 #define LOG_COUNTER_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_YELLOW, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
110 #else
111 #define LOG_COUNTER_EVENT(format, ...)
112 #define LOG_COUNTER_UPDATE_RENDER(format, ...)
113 #endif
114
115 #ifdef ENABLE_UPDATE_RENDER_THREAD_LOGGING
116 #define LOG_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_UPDATE_RENDER, COLOR_YELLOW, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
117 #define LOG_UPDATE_RENDER_TRACE LOG_THREAD_SYNC_TRACE(COLOR_YELLOW)
118 #define LOG_UPDATE_RENDER_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_YELLOW, format, ##__VA_ARGS__)
119 #else
120 #define LOG_UPDATE_RENDER(format, ...)
121 #define LOG_UPDATE_RENDER_TRACE
122 #define LOG_UPDATE_RENDER_TRACE_FMT(format, ...)
123 #endif
124
125 #ifdef ENABLE_EVENT_LOGGING
126 #define LOG_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_EVENT, COLOR_WHITE, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
127 #define LOG_EVENT_TRACE LOG_THREAD_SYNC_TRACE(COLOR_WHITE)
128 #define LOG_EVENT_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_WHITE, format, ##__VA_ARGS__)
129 #else
130 #define LOG_EVENT(format, ...)
131 #define LOG_EVENT_TRACE
132 #define LOG_EVENT_TRACE_FMT(format, ...)
133 #endif
134
135 } // unnamed namespace
136
137 } // namespace Adaptor
138
139 } // namespace Internal
140
141 } // namespace Dali
142
143 #endif // DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_DEBUG_H