Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / integration-api / debug.h
index ad0abd4..e95bebf 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTEGRATION_DEBUG_H__
-#define __DALI_INTEGRATION_DEBUG_H__
+#ifndef DALI_INTEGRATION_DEBUG_H
+#define DALI_INTEGRATION_DEBUG_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 // 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>
 
@@ -47,9 +49,9 @@ class Quaternion;
 
 // 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;
+using DebugIndexValuePair       = std::pair<Property::Index, Property::Value>;
+using DebugStringValueContainer = std::vector<Dali::StringValuePair>;
+using DebugIndexValueContainer  = std::vector<DebugIndexValuePair>;
 
 struct DebugPropertyValueMap
 {
@@ -85,7 +87,7 @@ DALI_CORE_API void LogMessage(enum DebugPriority level,const char *format, ...);
 /**
  * typedef for the logging function.
  */
-typedef void (*LogFunction)(DebugPriority priority, std::string& message);
+using LogFunction = void ( * )( DebugPriority, std::string & );
 
 /**
  * A log function has to be installed for every thread that wants to use logging.
@@ -109,44 +111,44 @@ DALI_CORE_API void UninstallLogFunction();
 /**
  * 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__)
 
-#define DALI_LOG_WARNING_NOFN(format, args...)     Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, 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, args...)     Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## args)
+#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, ASSERT_LOCATION, ## __VA_ARGS__)
 
 
 #else // DEBUG_ENABLED
 
 // Don't warn on release build
-#define DALI_LOG_WARNING(format, args...)
+#define DALI_LOG_WARNING(format, ...)
 
 #endif
 
@@ -181,8 +183,8 @@ enum LogLevel
 class DALI_CORE_API Filter
 {
 public:
-  typedef std::list<Filter*>           FilterList;
-  typedef std::list<Filter*>::iterator FilterIter;
+  using FilterList = std::list<Filter *>;
+  using FilterIter = std::list<Filter *>::iterator;
 
 public:
 
@@ -248,12 +250,19 @@ public:
   /**
    * Enable trace on all filters.
    */
-  void EnableGlobalTrace();
+  static void EnableGlobalTrace();
 
   /**
    * Disable trace on all filters.
    */
-  void DisableGlobalTrace();
+  static void DisableGlobalTrace();
+
+  /**
+   * Set log level for all filters.
+   *
+   * @param[in] level The log level
+   */
+  static void SetGlobalLogLevel( LogLevel level );
 
 private:
 
@@ -309,12 +318,21 @@ public:
 
 #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
 
@@ -342,16 +360,16 @@ public:
 };
 
 
-#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, ASSERT_LOCATION, ## __VA_ARGS__)
 
 #define DALI_LOG_TRACE_METHOD(filter)                                      \
-  Dali::Integration::Log::TraceObj debugTraceObj(filter, __PRETTY_FUNCTION__)
+  Dali::Integration::Log::TraceObj debugTraceObj(filter, ASSERT_LOCATION)
 
 
 #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)
 
 
@@ -395,7 +413,7 @@ public: \
 /**
  * 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
@@ -418,7 +436,7 @@ public: \
 #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)
@@ -454,4 +472,4 @@ void GetNanoseconds( uint64_t& timeInNanoseconds );
 } // Dali
 
 
-#endif // __DALI_INTEGRATION_DEBUG_H__
+#endif // DALI_INTEGRATION_DEBUG_H