From 1716451033063812056349156332128984540962 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 7 Nov 2023 18:55:32 -0500 Subject: Add fmt library to api --- log.cpp | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'log.cpp') diff --git a/log.cpp b/log.cpp index f8318cc3..e35b3663 100644 --- a/log.cpp +++ b/log.cpp @@ -162,6 +162,55 @@ void BinaryNinja::LogAlert(const char* fmt, ...) } +void BinaryNinja::LogFV(BNLogLevel level, fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + Log(level, "%s", value.c_str()); +} + + +void BinaryNinja::LogTraceFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogTrace("%s", value.c_str()); +} + + +void BinaryNinja::LogDebugFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogDebug("%s", value.c_str()); +} + + +void BinaryNinja::LogInfoFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogInfo("%s", value.c_str()); +} + + +void BinaryNinja::LogWarnFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogWarn("%s", value.c_str()); +} + + +void BinaryNinja::LogErrorFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogError("%s", value.c_str()); +} + + +void BinaryNinja::LogAlertFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogAlert("%s", value.c_str()); +} + + void BinaryNinja::LogToStdout(BNLogLevel minimumLevel) { BNLogToStdout(minimumLevel); @@ -267,6 +316,55 @@ void Logger::LogAlert(const char* fmt, ...) } +void Logger::LogFV(BNLogLevel level, fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + Log(level, "%s", value.c_str()); +} + + +void Logger::LogTraceFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogTrace("%s", value.c_str()); +} + + +void Logger::LogDebugFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogDebug("%s", value.c_str()); +} + + +void Logger::LogInfoFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogInfo("%s", value.c_str()); +} + + +void Logger::LogWarnFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogWarn("%s", value.c_str()); +} + + +void Logger::LogErrorFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogError("%s", value.c_str()); +} + + +void Logger::LogAlertFV(fmt::string_view format, fmt::format_args args) +{ + std::string value = fmt::vformat(format, args); + LogAlert("%s", value.c_str()); +} + + string Logger::GetName() { char* name = BNLoggerGetName(m_object); -- cgit v1.3.1