aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/utils/logging/Macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'arm_compute/core/utils/logging/Macros.h')
-rw-r--r--arm_compute/core/utils/logging/Macros.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/arm_compute/core/utils/logging/Macros.h b/arm_compute/core/utils/logging/Macros.h
index 5593030261..6c5bb32144 100644
--- a/arm_compute/core/utils/logging/Macros.h
+++ b/arm_compute/core/utils/logging/Macros.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 ARM Limited.
+ * Copyright (c) 2017-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -40,14 +40,17 @@
} \
} 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) \
- { \
- __logger->log(log_level, fmt, __VA_ARGS__); \
- } \
+#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) \
+ { \
+ size_t size = ::snprintf(nullptr, 0, fmt, __VA_ARGS__) + 1; \
+ auto char_str = support::cpp14::make_unique<char[]>(size); \
+ ::snprintf(char_str.get(), size, #fmt, __VA_ARGS__); \
+ __logger->log(log_level, std::string(char_str.get(), char_str.get() + size - 1)); \
+ } \
} while(false)
#define ARM_COMPUTE_LOG_STREAM(logger_name, log_level, stream) \