From 425f2aa013a9051a15b58a722668358a2dae5c70 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 20 Oct 2020 15:37:02 -0400 Subject: Common/Log: Add basic fmt-capable functions to the interface. Provides a basic extension to the interface to begin migration off of the printf-based logging system. Everything will go through macros with the same style naming as the old logging system, except the macros will have the _FMT suffix, while the migration is in process. This allows for peacemeal migration over time instead of pulling everything out and replacing it all in a single pull request, which makes for much easier reviewing. --- Source/Core/AudioCommon/CubebUtils.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Source/Core/AudioCommon/CubebUtils.cpp') diff --git a/Source/Core/AudioCommon/CubebUtils.cpp b/Source/Core/AudioCommon/CubebUtils.cpp index b4af87115b..2088956e4b 100644 --- a/Source/Core/AudioCommon/CubebUtils.cpp +++ b/Source/Core/AudioCommon/CubebUtils.cpp @@ -18,19 +18,19 @@ static ptrdiff_t s_path_cutoff_point = 0; static void LogCallback(const char* format, ...) { - if (!Common::Log::LogManager::GetInstance()) + auto* instance = Common::Log::LogManager::GetInstance(); + if (instance == nullptr) return; va_list args; va_start(args, format); - const char* filename = va_arg(args, const char*) + s_path_cutoff_point; - int lineno = va_arg(args, int); - std::string adapted_format(StripSpaces(format + strlen("%s:%d:"))); - - Common::Log::LogManager::GetInstance()->LogWithFullPath( - Common::Log::LNOTICE, Common::Log::AUDIO, filename, lineno, adapted_format.c_str(), args); + const int lineno = va_arg(args, int); + const std::string adapted_format(StripSpaces(format + strlen("%s:%d:"))); + const std::string message = StringFromFormatV(adapted_format.c_str(), args); va_end(args); + + instance->Log(Common::Log::LNOTICE, Common::Log::AUDIO, filename, lineno, message.c_str()); } static void DestroyContext(cubeb* ctx) -- cgit v1.2.3