Dali 3D User Interface Engine
thread-synchronization-debug.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__
2 #define __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__
3 
4 /*
5  * Copyright (c) 2015 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
23 
24 namespace Dali
25 {
26 
27 namespace Internal
28 {
29 
30 namespace Adaptor
31 {
32 
33 namespace
34 {
35 // Uncomment next line for FULL logging of the ThreadSynchronization class in release mode
36 //#define RELEASE_BUILD_LOGGING
37 
38 #ifdef DEBUG_ENABLED
39 
40 #define ENABLE_LOG_IN_COLOR
41 #define ENABLE_VSYNC_COUNTER_LOGGING
42 #define ENABLE_UPDATE_COUNTER_LOGGING
43 #define ENABLE_VSYNC_THREAD_LOGGING
44 #define ENABLE_UPDATE_THREAD_LOGGING
45 #define ENABLE_RENDER_THREAD_LOGGING
46 #define ENABLE_EVENT_LOGGING
47 
48 #define DEBUG_LEVEL_COUNTER Debug::Verbose
49 #define DEBUG_LEVEL_VSYNC Debug::General
50 #define DEBUG_LEVEL_UPDATE Debug::General
51 #define DEBUG_LEVEL_RENDER Debug::General
52 #define DEBUG_LEVEL_EVENT Debug::Concise
53 
54 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_THREAD_SYNC" );
55 
56 #define LOG_THREAD_SYNC(level, color, format, args...) \
57  DALI_LOG_INFO( gLogFilter, level, "%s" format "%s\n", color, ## args, COLOR_CLEAR )
58 
59 #define LOG_THREAD_SYNC_TRACE(color) \
60  Dali::Integration::Log::TraceObj debugTraceObj( gLogFilter, "%s%s%s", color, __FUNCTION__, COLOR_CLEAR ); \
61  if( ! gLogFilter->IsTraceEnabled() ) { LOG_THREAD_SYNC( Debug::Concise, color, "%s", __FUNCTION__ ); }
62 
63 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, args...) \
64  Dali::Integration::Log::TraceObj debugTraceObj( gLogFilter, "%s%s: " format "%s", color, __FUNCTION__, ## args, COLOR_CLEAR ); \
65  if( ! gLogFilter->IsTraceEnabled() ) { LOG_THREAD_SYNC( Debug::Concise, color, "%s: " format, __FUNCTION__, ## args ); }
66 
67 #elif defined( RELEASE_BUILD_LOGGING )
68 
69 #define ENABLE_LOG_IN_COLOR
70 #define ENABLE_VSYNC_COUNTER_LOGGING
71 #define ENABLE_UPDATE_COUNTER_LOGGING
72 #define ENABLE_VSYNC_THREAD_LOGGING
73 #define ENABLE_UPDATE_THREAD_LOGGING
74 #define ENABLE_RENDER_THREAD_LOGGING
75 #define ENABLE_EVENT_LOGGING
76 
77 #define DEBUG_LEVEL_COUNTER 0
78 #define DEBUG_LEVEL_VSYNC 0
79 #define DEBUG_LEVEL_UPDATE 0
80 #define DEBUG_LEVEL_RENDER 0
81 #define DEBUG_LEVEL_EVENT 0
82 
83 #define LOG_THREAD_SYNC(level, color, format, args...) \
84  Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s" format "%s\n", color, ## args, COLOR_CLEAR )
85 
86 #define LOG_THREAD_SYNC_TRACE(color) \
87  Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s%s%s\n", color, __FUNCTION__, COLOR_CLEAR )
88 
89 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, args...) \
90  Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s%s: " format "%s\n", color, __FUNCTION__, ## args, COLOR_CLEAR )
91 
92 #else
93 
94 #define LOG_THREAD_SYNC(level, color, format, args...)
95 #define LOG_THREAD_SYNC_TRACE(color)
96 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, args...)
97 
98 #endif // DEBUG_ENABLED
99 
100 #ifdef ENABLE_LOG_IN_COLOR
101 #define COLOR_RED "\033[31m"
102 #define COLOR_YELLOW "\033[33m"
103 #define COLOR_BLUE "\033[34m"
104 #define COLOR_LIGHT_RED "\033[91m"
105 #define COLOR_LIGHT_YELLOW "\033[93m"
106 #define COLOR_LIGHT_BLUE "\033[94m"
107 #define COLOR_WHITE "\033[97m"
108 #define COLOR_CLEAR "\033[0m"
109 #else
110 #define COLOR_RED
111 #define COLOR_YELLOW
112 #define COLOR_BLUE
113 #define COLOR_LIGHT_RED
114 #define COLOR_LIGHT_YELLOW
115 #define COLOR_LIGHT_BLUE
116 #define COLOR_WHITE
117 #define COLOR_CLEAR
118 #endif
119 
120 #ifdef ENABLE_VSYNC_COUNTER_LOGGING
121 #define LOG_VSYNC_COUNTER_VSYNC(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_RED, "%s: " format, __FUNCTION__, ## args)
122 #define LOG_VSYNC_COUNTER_UPDATE(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_YELLOW, "%s: " format, __FUNCTION__, ## args)
123 #else
124 #define LOG_VSYNC_COUNTER_VSYNC(format, args...)
125 #define LOG_VSYNC_COUNTER_UPDATE(format, args...)
126 #endif
127 
128 #ifdef ENABLE_UPDATE_COUNTER_LOGGING
129 #define LOG_UPDATE_COUNTER_UPDATE(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_YELLOW, "%s: " format, __FUNCTION__, ## args)
130 #define LOG_UPDATE_COUNTER_RENDER(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_BLUE, "%s: " format, __FUNCTION__, ## args)
131 #else
132 #define LOG_UPDATE_COUNTER_UPDATE(format, args...)
133 #define LOG_UPDATE_COUNTER_RENDER(format, args...)
134 #endif
135 
136 #ifdef ENABLE_VSYNC_THREAD_LOGGING
137 #define LOG_VSYNC(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_VSYNC, COLOR_RED, "%s: " format, __FUNCTION__, ## args)
138 #define LOG_VSYNC_TRACE LOG_THREAD_SYNC_TRACE(COLOR_RED)
139 #define LOG_VSYNC_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_RED, format, ## args)
140 #else
141 #define LOG_VSYNC(format, args...)
142 #define LOG_VSYNC_TRACE
143 #define LOG_VSYNC_TRACE_FMT(format, args...)
144 #endif
145 
146 #ifdef ENABLE_UPDATE_THREAD_LOGGING
147 #define LOG_UPDATE(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_UPDATE, COLOR_YELLOW, "%s: " format, __FUNCTION__, ## args)
148 #define LOG_UPDATE_TRACE LOG_THREAD_SYNC_TRACE(COLOR_YELLOW)
149 #define LOG_UPDATE_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_YELLOW, format, ## args)
150 #else
151 #define LOG_UPDATE(format, args...)
152 #define LOG_UPDATE_TRACE
153 #define LOG_UPDATE_TRACE_FMT(format, args...)
154 #endif
155 
156 #ifdef ENABLE_RENDER_THREAD_LOGGING
157 #define LOG_RENDER(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_RENDER, COLOR_BLUE, "%s: " format, __FUNCTION__, ## args)
158 #define LOG_RENDER_TRACE LOG_THREAD_SYNC_TRACE(COLOR_BLUE)
159 #define LOG_RENDER_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_BLUE, format, ## args)
160 #else
161 #define LOG_RENDER(format, args...)
162 #define LOG_RENDER_TRACE
163 #define LOG_RENDER_TRACE_FMT(format, args...)
164 #endif
165 
166 #ifdef ENABLE_EVENT_LOGGING
167 #define LOG_EVENT(format, args...) LOG_THREAD_SYNC(DEBUG_LEVEL_EVENT, COLOR_WHITE, "%s: " format, __FUNCTION__, ## args)
168 #define LOG_EVENT_TRACE LOG_THREAD_SYNC_TRACE(COLOR_WHITE)
169 #define LOG_EVENT_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_WHITE, format, ## args)
170 #else
171 #define LOG_EVENT(format, args...)
172 #define LOG_EVENT_TRACE
173 #define LOG_EVENT_TRACE_FMT(format, args...)
174 #endif
175 } // unnamed namespace
176 
177 } // namespace Adaptor
178 
179 } // namespace Internal
180 
181 } // namespace Dali
182 
183 #endif // __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__
Dali Docs Home
Read more about Dali