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>
37 #define ENABLE_LOG_IN_COLOR 1
38 #define ENABLE_VSYNC_COUNTER_LOGGING 1
39 #define ENABLE_UPDATE_COUNTER_LOGGING 1
40 #define ENABLE_VSYNC_THREAD_LOGGING 1
41 #define ENABLE_UPDATE_THREAD_LOGGING 1
42 #define ENABLE_RENDER_THREAD_LOGGING 1
43 #define ENABLE_EVENT_LOGGING 1
45 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, true, "LOG_THREAD_SYNC" );
47 #define LOG_THREAD_SYNC(level, color, format, args...) \
48 if( gLogFilter && gLogFilter->IsEnabledFor( level ) ) { Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s" format "%s\n", color, ## args, COLOR_CLEAR ); }
50 #define LOG_THREAD_SYNC_TRACE(color) \
51 Dali::Integration::Log::TraceObj debugTraceObj( ( gLogFilter && gLogFilter->IsEnabledFor( Debug::Concise ) ) ? gLogFilter : NULL, "%s%s%s", color, __FUNCTION__, COLOR_CLEAR )
53 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, args...) \
54 Dali::Integration::Log::TraceObj debugTraceObj( ( gLogFilter && gLogFilter->IsEnabledFor( Debug::Concise ) ) ? gLogFilter : NULL, "%s%s: " format "%s", color, __FUNCTION__, ## args, COLOR_CLEAR )
56 #else // DEBUG_ENABLED
58 #define LOG_THREAD_SYNC(color, format, args...)
59 #define LOG_THREAD_SYNC_TRACE(color)
60 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, args...)
62 #endif // DEBUG_ENABLED
64 #ifdef ENABLE_LOG_IN_COLOR
65 #define COLOR_RED "\033[31m"
66 #define COLOR_YELLOW "\033[33m"
67 #define COLOR_BLUE "\033[34m"
68 #define COLOR_LIGHT_RED "\033[91m"
69 #define COLOR_LIGHT_YELLOW "\033[93m"
70 #define COLOR_LIGHT_BLUE "\033[94m"
71 #define COLOR_WHITE "\033[97m"
72 #define COLOR_CLEAR "\033[0m"
77 #define COLOR_LIGHT_RED
78 #define COLOR_LIGHT_YELLOW
79 #define COLOR_LIGHT_BLUE
84 #ifdef ENABLE_VSYNC_COUNTER_LOGGING
85 #define LOG_VSYNC_COUNTER_VSYNC(format, args...) LOG_THREAD_SYNC(Debug::Verbose, COLOR_LIGHT_RED, "%s: " format, __FUNCTION__, ## args)
86 #define LOG_VSYNC_COUNTER_UPDATE(format, args...) LOG_THREAD_SYNC(Debug::Verbose, COLOR_LIGHT_YELLOW, "%s: " format, __FUNCTION__, ## args)
88 #define LOG_VSYNC_COUNTER_VSYNC(format, args...)
89 #define LOG_VSYNC_COUNTER_UPDATE(format, args...)
92 #ifdef ENABLE_UPDATE_COUNTER_LOGGING
93 #define LOG_UPDATE_COUNTER_UPDATE(format, args...) LOG_THREAD_SYNC(Debug::Verbose, COLOR_YELLOW, "%s: " format, __FUNCTION__, ## args)
94 #define LOG_UPDATE_COUNTER_RENDER(format, args...) LOG_THREAD_SYNC(Debug::Verbose, COLOR_LIGHT_BLUE, "%s: " format, __FUNCTION__, ## args)
96 #define LOG_UPDATE_COUNTER_UPDATE(format, args...)
97 #define LOG_UPDATE_COUNTER_RENDER(format, args...)
100 #ifdef ENABLE_VSYNC_THREAD_LOGGING
101 #define LOG_VSYNC(format, args...) LOG_THREAD_SYNC(Debug::General, COLOR_RED, "%s: " format, __FUNCTION__, ## args)
102 #define LOG_VSYNC_TRACE LOG_THREAD_SYNC_TRACE(COLOR_RED)
103 #define LOG_VSYNC_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_RED, format, ## args)
105 #define LOG_VSYNC(format, args...)
106 #define LOG_VSYNC_TRACE
107 #define LOG_VSYNC_TRACE_FMT(format, args...)
110 #ifdef ENABLE_UPDATE_THREAD_LOGGING
111 #define LOG_UPDATE(format, args...) LOG_THREAD_SYNC(Debug::General, COLOR_YELLOW, "%s: " format, __FUNCTION__, ## args)
112 #define LOG_UPDATE_TRACE LOG_THREAD_SYNC_TRACE(COLOR_YELLOW)
113 #define LOG_UPDATE_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_YELLOW, format, ## args)
115 #define LOG_UPDATE(format, args...)
116 #define LOG_UPDATE_TRACE
117 #define LOG_UPDATE_TRACE_FMT(format, args...)
120 #ifdef ENABLE_RENDER_THREAD_LOGGING
121 #define LOG_RENDER(format, args...) LOG_THREAD_SYNC(Debug::General, COLOR_BLUE, "%s: " format, __FUNCTION__, ## args)
122 #define LOG_RENDER_TRACE LOG_THREAD_SYNC_TRACE(COLOR_BLUE)
123 #define LOG_RENDER_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_BLUE, format, ## args)
125 #define LOG_RENDER(format, args...)
126 #define LOG_RENDER_TRACE
127 #define LOG_RENDER_TRACE_FMT(format, args...)
130 #ifdef ENABLE_EVENT_LOGGING
131 #define LOG_EVENT(format, args...) LOG_THREAD_SYNC(Debug::Concise, COLOR_WHITE, "%s: " format, __FUNCTION__, ## args)
132 #define LOG_EVENT_TRACE LOG_THREAD_SYNC_TRACE(COLOR_WHITE)
133 #define LOG_EVENT_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_WHITE, format, ## args)
135 #define LOG_EVENT(format, args...)
136 #define LOG_EVENT_TRACE
137 #define LOG_EVENT_TRACE_FMT(format, args...)
139 } // unnamed namespace
141 } // namespace Adaptor
143 } // namespace Internal
147 #endif // __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__