#ifndef __DALI_INTEGRATION_DEBUG_H__
#define __DALI_INTEGRATION_DEBUG_H__
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// EXTERNAL INCLUDES
#include <string>
+#include <sstream>
+#include <iostream>
#include <list>
+#include <stdint.h>
+
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
class Matrix;
class Quaternion;
-namespace Integration
-{
-namespace Log
+#if defined(DEBUG_ENABLED)
+
+// Less opaque types for debugger
+typedef std::vector<Dali::Property::Value> DebugPropertyValueArray;
+typedef std::pair< Property::Index, Property::Value > DebugIndexValuePair;
+typedef std::vector<Dali::StringValuePair> DebugStringValueContainer;
+typedef std::vector< DebugIndexValuePair > DebugIndexValueContainer;
+
+struct DebugPropertyValueMap
{
+ DebugStringValueContainer stringValues;
+ DebugIndexValueContainer intValues;
+};
-// environment variable for enabling/disabling logging in different threads
-#define DALI_ENV_ENABLE_LOG "DALI_ENABLE_LOG"
-// values of the environment variable
-#define DALI_LOG_OFF "FALSE" ///< disable log messages from all threads. Do not log resource creation / destruction
-#define DALI_LOG_EVENT_THREAD "EVENT" ///< enable log messages from event thread. Do not log resource creation / destruction
-#define DALI_LOG_UPDATE_THREAD "UPDATE" ///< enable log messages from update thread. Do not log resource creation / destruction
-#define DALI_LOG_RENDER_THREAD "RENDER" ///< enable log messages from render thread. Do not log resource creation / destruction
-#define DALI_LOG_RESOURCE_THREADS "RESOURCE_LOADER" ///< enable log messages from render thread. Do not log resource creation / destruction
-#define DALI_LOG_ALL_THREADS "ALL" ///< enable log messages from all threads. Do not log resource creation / destruction
-#define DALI_LOG_RESOURCE_LIFETIME "RESOURCE_LOG" ///< log resource creation / destruction. Enables logging on all threads.
+// Fake globals for gdb typedefs
+extern Dali::DebugPropertyValueArray gValueArray;
+extern Dali::DebugPropertyValueMap gValueMap;
-// environment variable for enabling/disabling fps tracking
-#define DALI_ENV_FPS_TRACKING "DALI_FPS_TRACKING"
+#endif
-// environment variable for enabling/disabling fps tracking
-#define DALI_ENV_UPDATE_STATUS_INTERVAL "DALI_UPDATE_STATUS_INTERVAL"
+namespace Integration
+{
+namespace Log
+{
enum DebugPriority
{
DebugInfo,
DebugWarning,
- DebugError,
- DebugResources
-};
-
-/**
- * Control logging in separate threads.
- * If DEBUG_ENABLED macro is not defined, only errors and resource lifetime messages are logged.
- */
-enum LoggingOptions
-{
- LogNone = 0,
- LogEventThread = 1 << 0,
- LogUpdateThread = 1 << 1,
- LogRenderThread = 1 << 2,
- LogResourceThreads = 1 << 3,
- LogResourceLifetime = 1 << 4
+ DebugError
};
/**
- * Return log settings (bitfield) based on the value set in environment
- * @param[in] setting the string contained in DALI_ENABLE_LOG env. variable (or NULL if not set)
- * @return a bitfield with all the relevant LoggingOptions values set
- */
-DALI_IMPORT_API unsigned int ParseLogOptions (const char* setting);
-
-/**
* Used by logging macros to log a message along with function/class name
* @param level debug level
* @param format string format
*/
-DALI_IMPORT_API void LogMessage(enum DebugPriority level,const char *format, ...);
+DALI_CORE_API void LogMessage(enum DebugPriority level,const char *format, ...);
/**
* typedef for the logging function.
* @param logFunction the log function to install
* @param logOpts the log options to save in thread
*/
-DALI_IMPORT_API void InstallLogFunction(const LogFunction& logFunction, unsigned int logOpts);
+DALI_CORE_API void InstallLogFunction(const LogFunction& logFunction);
/**
* A log function has to be uninstalled for every thread that wants to use logging.
* The log function can be different for each thread.
*/
-DALI_IMPORT_API void UninstallLogFunction();
+DALI_CORE_API void UninstallLogFunction();
/********************************************************************************
* Error/Warning macros. *
/**
* Provides unfiltered logging for global error level messages
*/
-#define DALI_LOG_ERROR(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%s " format, __PRETTY_FUNCTION__, ## args)
+#define DALI_LOG_ERROR(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%s " format, __FUNCTION__, ## __VA_ARGS__)
-#define DALI_LOG_ERROR_NOFN(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, format, ## args)
+#define DALI_LOG_ERROR_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, format, ## __VA_ARGS__)
-/**
- * Provides unfiltered logging for resource usage
- */
-#define DALI_LOG_RESOURCE(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugResources, format, ## args)
+#define DALI_LOG_WARNING_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, format, ## __VA_ARGS__)
/**
* Provides unfiltered logging for fps monitor
*/
-#define DALI_LOG_FPS(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## args)
+#define DALI_LOG_FPS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__)
/**
* Provides unfiltered logging for update status
*/
-#define DALI_LOG_UPDATE_STATUS(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## args)
+#define DALI_LOG_UPDATE_STATUS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__)
/**
* Provides unfiltered logging for render information
*/
-#define DALI_LOG_RENDER_INFO(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## args)
+#define DALI_LOG_RENDER_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__)
+
+/**
+ * Provides unfiltered logging for release
+ */
+#define DALI_LOG_RELEASE_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__)
#ifdef DEBUG_ENABLED
/**
* Provides unfiltered logging for global warning level messages
*/
-#define DALI_LOG_WARNING(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, "%s " format, __PRETTY_FUNCTION__, ## args)
+#define DALI_LOG_WARNING(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, "%s " format, __PRETTY_FUNCTION__, ## __VA_ARGS__)
#else // DEBUG_ENABLED
// Don't warn on release build
-#define DALI_LOG_WARNING(format, args...)
+#define DALI_LOG_WARNING(format, ...)
#endif
* It provides the ability to turn tracing on or off.
*
*/
-class DALI_IMPORT_API Filter
+class DALI_CORE_API Filter
{
public:
typedef std::list<Filter*> FilterList;
static Filter *gElement;
static Filter *gActor;
static Filter *gShader;
- static Filter *gDynamics;
private:
LogLevel mLoggingLevel;
#ifdef DEBUG_ENABLED
-#define DALI_LOG_INFO(filter, level, format, args...) \
- if(filter && filter->IsEnabledFor(level)) { filter->Log(level, format, ## args); }
+#define DALI_LOG_INFO(filter, level, format, ...) \
+ if(filter && filter->IsEnabledFor(level)) { filter->Log(level, format, ## __VA_ARGS__); }
+
+#define DALI_LOG_STREAM( filter, level, stream ) \
+ if(filter && filter->IsEnabledFor(level)) \
+ { \
+ std::ostringstream o; \
+ o << stream << std::endl; \
+ filter->Log(level, "%s", o.str().c_str()); \
+ }
#else // DEBUG_ENABLED
-#define DALI_LOG_INFO(filter, level, format, args...)
+#define DALI_LOG_INFO(filter, level, format, ...)
+#define DALI_LOG_STREAM( filter, level, stream )
#endif // DEBUG_ENABLED
#ifdef DEBUG_ENABLED
-class DALI_IMPORT_API TraceObj
+class DALI_CORE_API TraceObj
{
public:
TraceObj(Filter* filter, const char* fmt, ...);
};
-#define DALI_LOG_TRACE_METHOD_FMT(filter, format, args...) \
- Dali::Integration::Log::TraceObj debugTraceObj(filter, "%s: " format, __PRETTY_FUNCTION__, ## args)
+#define DALI_LOG_TRACE_METHOD_FMT(filter, format, ...) \
+ Dali::Integration::Log::TraceObj debugTraceObj(filter, "%s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__)
#define DALI_LOG_TRACE_METHOD(filter) \
Dali::Integration::Log::TraceObj debugTraceObj(filter, __PRETTY_FUNCTION__)
#else // DEBUG_ENABLED
-#define DALI_LOG_TRACE_METHOD_FMT(filter, format, args...)
+#define DALI_LOG_TRACE_METHOD_FMT(filter, format, ...)
#define DALI_LOG_TRACE_METHOD(filter)
std::string mDebugString;
/**
+ * Print all the actor tree names
+ **/
+#define DALI_LOG_ACTOR_TREE( node ) { \
+ std::stringstream branch; \
+ Node* tempNode = node; \
+ while( tempNode ) { \
+ branch << "<" << tempNode->mDebugString << ">::"; \
+ tempNode = tempNode->GetParent(); \
+ } \
+ DALI_LOG_ERROR_NOFN("Actor tree: %s\n", branch.str().c_str()); \
+}
+
+/**
* Allows one object to set another object's debug string
*/
#define DALI_LOG_SET_OBJECT_STRING(object, string) (object->mDebugString = string)
/**
* Allows one object to set another object's std::string easily
*/
-#define DALI_LOG_FMT_OBJECT_STRING(object, fmt, args...) (object->mDebugString = FormatToString(fmt, ## args))
+#define DALI_LOG_FMT_OBJECT_STRING(object, fmt, ...) (object->mDebugString = FormatToString(fmt, ## __VA_ARGS__))
/**
* Allows one object to get another object's debug string
#else // DEBUG_ENABLED
#define DALI_LOG_OBJECT_STRING_DECLARATION
+#define DALI_LOG_ACTOR_TREE(node)
#define DALI_LOG_SET_OBJECT_STRING(object, string)
-#define DALI_LOG_FMT_OBJECT_STRING(object, fmt, args...)
+#define DALI_LOG_FMT_OBJECT_STRING(object, fmt, ...)
#define DALI_LOG_GET_OBJECT_STRING(object)
#define DALI_LOG_GET_OBJECT_C_STR(object) ""
#define DALI_LOG_OBJECT(filter, object)
#endif
/********************************************************************************
- * Helper writers *
+ * Time instrumentation *
********************************************************************************/
-/**
- * Helper method to translate a color to a string.
- * @param[in] color - the color to translate
- * @return string - the text representation of the color.
- */
-DALI_IMPORT_API std::string ColorToString(const Vector4& color);
-
-/**
- * Helper method to translate a vector4 to a string.
- * @param[in] v - the vector
- * @param[in] precision - the precision to write the float data.
- * @param[in] indent - the indent level to use.
- * @return string - the text representation of the vector.
- */
-DALI_IMPORT_API std::string Vector4ToString(const Vector4& v, size_t precision=3, size_t indent=0);
-
-/**
- * Helper method to translate a vector4 to a string.
- * @param[in] v - the vector
- * @param[in] precision - the precision to write the float data.
- * @param[in] indent - the indent level to use.
- * @return string - the text representation of the vector.
- */
-DALI_IMPORT_API std::string Vector3ToString(const Vector3& v, size_t precision=3, size_t indent=0);
-
-/**
- * Helper method to translate a quaternion to a string.
- * @param[in] q the quaternion
- * @param[in] precision - the precision to write the float data.
- * @param[in] indent - the indent level to use.
- * @return string - the text representation of the quaternion.
- */
-DALI_IMPORT_API std::string QuaternionToString(const Quaternion& q, size_t precision=3, size_t indent=0);
-
-/**
- * Helper method to translate a 3x3 matrix to a string.
- * @param[in] m - the matrix
- * @param[in] precision - the precision to write the float data.
- * @param[in] indent - the indent level to use.
- * @return string - the text representation of the vector.
- */
-DALI_IMPORT_API std::string Matrix3ToString(const Matrix3& m, size_t precision=3, size_t indent=0);
-
-/**
- * Helper method to translate a 4x4 matrix to a string.
- * @param[in] m - the matrix
- * @param[in] precision - the precision to write the float data.
- * @param[in] indent - the indent level to use.
- * @return string - the text representation of the vector.
- */
-DALI_IMPORT_API std::string MatrixToString(const Matrix& m, size_t precision=3, size_t indent=0);
-
-#ifdef DEBUG_ENABLED
-
-
-/**
- * Filtered write of a matrix
- */
-#define DALI_LOG_MATRIX(filter, matrix) DALI_LOG_INFO(filter, Debug::General, MatrixToString(matrix))
+#if defined(DEBUG_ENABLED)
-/**
- * Filtered write of a vector
- */
-#define DALI_LOG_VECTOR4(filter, vector) DALI_LOG_INFO(filter, Debug::General, Vector4ToString(vector))
+void GetNanoseconds( uint64_t& timeInNanoseconds );
-/**
- * Filtered write of a vector
- */
-#define DALI_LOG_VECTOR3(filter, vector) DALI_LOG_INFO(filter, Debug::General, Vector3ToString(vector))
+#define DALI_LOG_TIMER_START( timeVariable ) \
+ uint64_t timeVariable##1; \
+ Debug::GetNanoseconds( timeVariable##1 );
-/**
- * Filtered write of a color
- */
-#define DALI_LOG_COLOR(filter, color) DALI_LOG_INFO(filter, Debug::General, ColorToString(color))
+#define DALI_LOG_TIMER_END( timeVariable, filter, level, preString) \
+ uint64_t timeVariable##2; \
+ Debug::GetNanoseconds( timeVariable##2 ); \
+ DALI_LOG_INFO( filter, level, preString " %ld uSec\n", ((timeVariable##2-timeVariable##1)/1000));
-#else
+#else // DEBUG_ENABLED
-#define DALI_LOG_MATRIX(filter, matrix)
-#define DALI_LOG_VECTOR4(filter,vector)
-#define DALI_LOG_VECTOR3(filter,vector)
-#define DALI_LOG_COLOR(filter, color)
+#define DALI_LOG_TIMER_START( timeVariable )
+#define DALI_LOG_TIMER_END( timeVariable, filter, level, preString)
#endif
-}}} // Dali/Integration/Debug namespaces
+} // Debug
+} // Integration
+} // Dali
#endif // __DALI_INTEGRATION_DEBUG_H__