summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2026-03-20 13:45:24 -0400
committerPeter LaFosse <peter@vector35.com>2026-03-20 13:57:29 -0400
commitc425acdb51f6b1dfcfd6e5ff56a4c3967507ccba (patch)
tree9411ec87e38cc97936f945098ca4db46a0bb15cc
parent52014ae4076181ca5ea42a17442d63cc727b28f1 (diff)
Wrap LogTrace FV/F functions with BN_ENABLE_LOG_TRACE guard
The *FV and *F variants were unconditionally calling fmt::vformat (allocating/formatting strings) even when trace logging was compiled out, since only the underlying LogTrace* callees were guarded. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--binaryninjaapi.h12
-rw-r--r--log.cpp12
2 files changed, 24 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 2feff8d8..7b46f97f 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -944,7 +944,9 @@ namespace BinaryNinja {
template<typename... T>
void LogTraceF(fmt::format_string<T...> format, T&&... args)
{
+#ifdef BN_ENABLE_LOG_TRACE
LogTraceFV(format, fmt::make_format_args(args...));
+#endif
}
/*! LogDebug only writes text to the error console if the console is set to log level: DebugLog
@@ -1058,7 +1060,9 @@ namespace BinaryNinja {
template <typename... T>
void LogTraceForExceptionF(const std::exception& e, fmt::format_string<T...> format, T&&... args)
{
+#ifdef BN_ENABLE_LOG_TRACE
LogTraceForExceptionFV(e, format, fmt::make_format_args(args...));
+#endif
}
/*! LogDebugForExceptionF only writes text to the error console if the console is set to log level: DebugLog
@@ -1175,7 +1179,9 @@ namespace BinaryNinja {
template <typename... T>
void LogTraceWithStackTraceF(fmt::format_string<T...> format, T&&... args)
{
+#ifdef BN_ENABLE_LOG_TRACE
LogTraceWithStackTraceFV(format, fmt::make_format_args(args...));
+#endif
}
/*! LogDebugWithStackTraceF only writes text to the error console if the console is set to log level: DebugLog
@@ -1581,7 +1587,9 @@ namespace BinaryNinja {
template<typename... T>
void LogTraceF(fmt::format_string<T...> format, T&&... args)
{
+#ifdef BN_ENABLE_LOG_TRACE
LogTraceFV(format, fmt::make_format_args(args...));
+#endif
}
/*! LogDebug only writes text to the error console if the console is set to log level: DebugLog
@@ -1682,7 +1690,9 @@ namespace BinaryNinja {
template <typename... T>
void LogTraceForExceptionF(const std::exception& e, fmt::format_string<T...> format, T&&... args)
{
+#ifdef BN_ENABLE_LOG_TRACE
LogTraceForExceptionFV(e, format, fmt::make_format_args(args...));
+#endif
}
/*! LogDebugForExceptionF only writes text to the error console if the console is set to log level:
@@ -1785,7 +1795,9 @@ namespace BinaryNinja {
template <typename... T>
void LogTraceWithStackTraceF(fmt::format_string<T...> format, T&&... args)
{
+#ifdef BN_ENABLE_LOG_TRACE
LogTraceWithStackTraceFV(format, fmt::make_format_args(args...));
+#endif
}
/*! LogDebugWithStackTraceF only writes text to the error console if the console is set to log level:
diff --git a/log.cpp b/log.cpp
index 69285bb9..1f9635d2 100644
--- a/log.cpp
+++ b/log.cpp
@@ -408,8 +408,10 @@ void BinaryNinja::LogFV(BNLogLevel level, fmt::string_view format, fmt::format_a
void BinaryNinja::LogTraceFV(fmt::string_view format, fmt::format_args args)
{
+#ifdef BN_ENABLE_LOG_TRACE
std::string value = fmt::vformat(format, args);
LogTrace("%s", value.c_str());
+#endif
}
@@ -423,8 +425,10 @@ void BinaryNinja::LogForExceptionFV(
void BinaryNinja::LogTraceForExceptionFV(const std::exception& e, fmt::string_view format, fmt::format_args args)
{
+#ifdef BN_ENABLE_LOG_TRACE
std::string value = fmt::vformat(format, args);
LogTraceForException(e, "%s", value.c_str());
+#endif
}
@@ -437,8 +441,10 @@ void BinaryNinja::LogWithStackTraceFV(BNLogLevel level, fmt::string_view format,
void BinaryNinja::LogTraceWithStackTraceFV(fmt::string_view format, fmt::format_args args)
{
+#ifdef BN_ENABLE_LOG_TRACE
std::string value = fmt::vformat(format, args);
LogTraceWithStackTrace("%s", value.c_str());
+#endif
}
@@ -700,8 +706,10 @@ void Logger::LogFV(BNLogLevel level, fmt::string_view format, fmt::format_args a
void Logger::LogTraceFV(fmt::string_view format, fmt::format_args args)
{
+#ifdef BN_ENABLE_LOG_TRACE
std::string value = fmt::vformat(format, args);
LogTrace("%s", value.c_str());
+#endif
}
@@ -715,8 +723,10 @@ void Logger::LogForExceptionFV(
void Logger::LogTraceForExceptionFV(const std::exception& e, fmt::string_view format, fmt::format_args args)
{
+#ifdef BN_ENABLE_LOG_TRACE
std::string value = fmt::vformat(format, args);
LogTraceForException(e, "%s", value.c_str());
+#endif
}
@@ -729,8 +739,10 @@ void Logger::LogWithStackTraceFV(BNLogLevel level, fmt::string_view format, fmt:
void Logger::LogTraceWithStackTraceFV(fmt::string_view format, fmt::format_args args)
{
+#ifdef BN_ENABLE_LOG_TRACE
std::string value = fmt::vformat(format, args);
LogTraceWithStackTrace("%s", value.c_str());
+#endif
}