diff options
Diffstat (limited to 'arm_compute/core/utils/logging/Macros.h')
-rw-r--r-- | arm_compute/core/utils/logging/Macros.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/arm_compute/core/utils/logging/Macros.h b/arm_compute/core/utils/logging/Macros.h index 1108dd3800..4d5aa5fe2c 100644 --- a/arm_compute/core/utils/logging/Macros.h +++ b/arm_compute/core/utils/logging/Macros.h @@ -30,52 +30,66 @@ #ifdef ARM_COMPUTE_LOGGING_ENABLED +#ifdef __GNUC__ +inline std::string signature_name(const std::string &pretty_func) +{ + const auto scope_op = pretty_func.find("::"); + const auto begin = pretty_func.substr(0, scope_op).rfind(" ") + 1; + const auto end = pretty_func.rfind("(") - begin; + + return pretty_func.substr(begin, end) + "()"; +} +#define ARM_COMPUTE_SIGNATURE_NAME signature_name(__PRETTY_FUNCTION__) +#else /* __GNUC__ */ +#define ARM_COMPUTE_SIGNATURE_NAME (__func__) +#endif /* __GNUC__ */ + #define ARM_COMPUTE_LOG_MSG(logger_name, log_level, msg) \ do \ { \ auto __logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \ - if(__logger != nullptr) \ + if (__logger != nullptr) \ { \ __logger->log(log_level, msg); \ } \ - } while(false) + } while (false) #define ARM_COMPUTE_LOG_MSG_WITH_FUNCNAME(logger_name, log_level, msg) \ do \ { \ auto __logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \ - if(__logger != nullptr) \ + if (__logger != nullptr) \ { \ std::ostringstream s; \ - s << __func__ << ":" << msg; \ + s << ARM_COMPUTE_SIGNATURE_NAME << " : " << msg; \ __logger->log(log_level, s.str()); \ } \ - } while(false) + } while (false) #define ARM_COMPUTE_LOG_MSG_WITH_FORMAT(logger_name, log_level, fmt, ...) \ do \ { \ auto __logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \ - if(__logger != nullptr) \ + if (__logger != nullptr) \ { \ size_t size = ::snprintf(nullptr, 0, fmt, __VA_ARGS__) + 1; \ auto char_str = std::make_unique<char[]>(size); \ - ::snprintf(char_str.get(), size, #fmt, __VA_ARGS__); \ + ::snprintf(char_str.get(), size, fmt, __VA_ARGS__); \ __logger->log(log_level, std::string(char_str.get(), char_str.get() + size - 1)); \ } \ - } while(false) + } while (false) #define ARM_COMPUTE_LOG_STREAM(logger_name, log_level, stream) \ do \ { \ auto __logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \ - if(__logger != nullptr) \ + if (__logger != nullptr) \ { \ std::ostringstream s; \ s << stream; \ __logger->log(log_level, s.str()); \ } \ - } while(false) + } while (false) #else /* ARM_COMPUTE_LOGGING_ENABLED */ |