1 #ifndef __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__
2 #define __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/integration-api/debug.h>
35 // Uncomment next line for FULL logging of the ThreadSynchronization class in release mode
36 //#define RELEASE_BUILD_LOGGING
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
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
54 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_THREAD_SYNC" );
56 #define LOG_THREAD_SYNC(level, color, format, args...) \
57 DALI_LOG_INFO( gLogFilter, level, "%s" format "%s\n", color, ## args, COLOR_CLEAR )
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__ ); }
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 ); }
67 #elif defined( RELEASE_BUILD_LOGGING )
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
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
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 )
86 #define LOG_THREAD_SYNC_TRACE(color) \
87 Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s%s%s\n", color, __FUNCTION__, COLOR_CLEAR )
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 )
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...)
98 #endif // DEBUG_ENABLED
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"
113 #define COLOR_LIGHT_RED
114 #define COLOR_LIGHT_YELLOW
115 #define COLOR_LIGHT_BLUE
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)
124 #define LOG_VSYNC_COUNTER_VSYNC(format, args...)
125 #define LOG_VSYNC_COUNTER_UPDATE(format, args...)
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)
132 #define LOG_UPDATE_COUNTER_UPDATE(format, args...)
133 #define LOG_UPDATE_COUNTER_RENDER(format, args...)
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)
141 #define LOG_VSYNC(format, args...)
142 #define LOG_VSYNC_TRACE
143 #define LOG_VSYNC_TRACE_FMT(format, args...)
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)
151 #define LOG_UPDATE(format, args...)
152 #define LOG_UPDATE_TRACE
153 #define LOG_UPDATE_TRACE_FMT(format, args...)
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)
161 #define LOG_RENDER(format, args...)
162 #define LOG_RENDER_TRACE
163 #define LOG_RENDER_TRACE_FMT(format, args...)
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)
171 #define LOG_EVENT(format, args...)
172 #define LOG_EVENT_TRACE
173 #define LOG_EVENT_TRACE_FMT(format, args...)
175 } // unnamed namespace
177 } // namespace Adaptor
179 } // namespace Internal
183 #endif // __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__