X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fintegration-api%2Fdebug.h;h=8533270aa910e6491f218bbe75e2a307a67e3e17;hb=124494de5be1dbc24ab0a6e682434f9f936c0b41;hp=5b2f40c8ad19005dec295f766836b6732f8e2bf5;hpb=0741b58e8e53e8ea7b897c2e21aac6b4da733192;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/integration-api/debug.h b/dali/integration-api/debug.h index 5b2f40c..8533270 100644 --- a/dali/integration-api/debug.h +++ b/dali/integration-api/debug.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_DEBUG_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -78,19 +79,43 @@ namespace Log { enum DebugPriority { - DebugInfo, - DebugWarning, - DebugError + DEBUG, + INFO, + WARNING, + ERROR }; /** - * Used by logging macros to log a message along with function/class name + * Used by logging macros to log a message * @param level debug level * @param format string format */ DALI_CORE_API void LogMessage(enum DebugPriority level, const char* format, ...); /** + * Prefix macros to sync with dlog logger format + * __MODULE__ macro also defined at dlog-internal.h + */ +#ifndef DALI_LOG_FORMAT_PREFIX +#ifndef __MODULE__ +#define __MODULE__ (std::strrchr(__FILE__, '/') ? std::strrchr(__FILE__, '/') + 1 : __FILE__) +#endif +#define DALI_LOG_FORMAT_PREFIX "%s: %s(%d) > " +#define DALI_LOG_FORMAT_PREFIX_ARGS __MODULE__, __func__, __LINE__ +#endif + +/** + * Global logging macros to log a message along with function/class name and line + * @param level debug level + * @param format string format + */ +#define LogMessageWithFunctionLine(level, format, ...) \ + LogMessage(level, \ + (std::string(DALI_LOG_FORMAT_PREFIX) + std::string(format)).c_str(), \ + DALI_LOG_FORMAT_PREFIX_ARGS, \ + ##__VA_ARGS__) + +/** * typedef for the logging function. */ using LogFunction = void (*)(DebugPriority, std::string&); @@ -117,38 +142,43 @@ DALI_CORE_API void UninstallLogFunction(); /** * Provides unfiltered logging for global error level messages */ -#define DALI_LOG_ERROR(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%s " format, __FUNCTION__, ##__VA_ARGS__) +#define DALI_LOG_ERROR(format, ...) Dali::Integration::Log::LogMessageWithFunctionLine(Dali::Integration::Log::ERROR, format, ##__VA_ARGS__) -#define DALI_LOG_ERROR_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, format, ##__VA_ARGS__) +#define DALI_LOG_ERROR_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::ERROR, format, ##__VA_ARGS__) -#define DALI_LOG_WARNING_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, format, ##__VA_ARGS__) +#define DALI_LOG_WARNING_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::WARNING, format, ##__VA_ARGS__) /** * Provides unfiltered logging for fps monitor */ -#define DALI_LOG_FPS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ##__VA_ARGS__) +#define DALI_LOG_FPS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::INFO, format, ##__VA_ARGS__) /** * Provides unfiltered logging for update status */ -#define DALI_LOG_UPDATE_STATUS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ##__VA_ARGS__) +#define DALI_LOG_UPDATE_STATUS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::INFO, format, ##__VA_ARGS__) /** * Provides unfiltered logging for render information */ -#define DALI_LOG_RENDER_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ##__VA_ARGS__) +#define DALI_LOG_RENDER_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::INFO, 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__) +#define DALI_LOG_RELEASE_INFO(format, ...) Dali::Integration::Log::LogMessageWithFunctionLine(Dali::Integration::Log::INFO, format, ##__VA_ARGS__) + +/** + * Provides unfiltered logging for debuf information + */ +#define DALI_LOG_DEBUG_INFO(format, ...) Dali::Integration::Log::LogMessageWithFunctionLine(Dali::Integration::Log::DEBUG, format, ##__VA_ARGS__) #ifdef DEBUG_ENABLED /** * Provides unfiltered logging for global warning level messages */ -#define DALI_LOG_WARNING(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, "%s " format, ASSERT_LOCATION, ##__VA_ARGS__) +#define DALI_LOG_WARNING(format, ...) Dali::Integration::Log::LogMessageWithFunctionLine(Dali::Integration::Log::WARNING, "%s " format, ASSERT_LOCATION, ##__VA_ARGS__) #else // DEBUG_ENABLED @@ -339,10 +369,13 @@ public: #ifdef DEBUG_ENABLED -#define DALI_LOG_INFO(filter, level, format, ...) \ - if(filter && filter->IsEnabledFor(level)) \ - { \ - filter->Log(level, format, ##__VA_ARGS__); \ +#define DALI_LOG_INFO(filter, level, format, ...) \ + if(filter && filter->IsEnabledFor(level)) \ + { \ + filter->Log(level, \ + (std::string(DALI_LOG_FORMAT_PREFIX) + std::string(format)).c_str(), \ + DALI_LOG_FORMAT_PREFIX_ARGS, \ + ##__VA_ARGS__); \ } #define DALI_LOG_STREAM(filter, level, stream) \ @@ -366,7 +399,7 @@ public: /* * These macros allow the instrumentation of methods. These translate into calls - * to LogMessage(DebugInfo). + * to LogMessage(INFO). */ #ifdef DEBUG_ENABLED @@ -467,9 +500,15 @@ public: \ /******************************************************************************** * Time instrumentation * ********************************************************************************/ - #if defined(DEBUG_ENABLED) +/** + * @brief Get the monotonic time since the clock's epoch. + * + * @param[out] timeInNanoseconds The time in nanoseconds since the reference point. + * + * @note The maximum value timeInNanoseconds can hold is 0xFFFFFFFFFFFFFFFF which is 1.844674407e+19. Therefore, this can overflow after approximately 584 years. + */ void GetNanoseconds(uint64_t& timeInNanoseconds); #define DALI_LOG_TIMER_START(timeVariable) \