From 5b92d5076a0be89945fa0fc722749dd5fbfcdf4c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 14 Jun 2019 10:53:46 -0400 Subject: Common: Use fmt where applicable Begins the transition to using fmt for string formatting where applicable. Given fmt supports formatting std::string instances out of the box, we can remove now-unnecessary calls to .c_str() and .data(). Note that this change does not touch the actual logging subsystem aside from converting the final StringFromFormat call in the process over to fmt::format. Given our logging system is heavily used throughout the entire codebase, and converting that over will be quite a large change by itself, this will be tackled near the end of the conversion process. --- Source/Core/Common/Logging/LogManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Source/Core/Common/Logging/LogManager.cpp') diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 4e946e8fd2..5a23cc7945 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Common/Logging/LogManager.h" + #include #include #include @@ -10,12 +12,13 @@ #include #include +#include + #include "Common/CommonPaths.h" #include "Common/Config/Config.h" #include "Common/FileUtil.h" #include "Common/Logging/ConsoleListener.h" #include "Common/Logging/Log.h" -#include "Common/Logging/LogManager.h" #include "Common/StringUtil.h" #include "Common/Timer.h" @@ -207,9 +210,9 @@ void LogManager::LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE char temp[MAX_MSGLEN]; CharArrayFromFormatV(temp, MAX_MSGLEN, format, args); - std::string msg = - StringFromFormat("%s %s:%u %c[%s]: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, - line, LogTypes::LOG_LEVEL_TO_CHAR[(int)level], GetShortName(type), temp); + const std::string msg = + fmt::format("{} {}:{} {}[{}]: {}\n", Common::Timer::GetTimeFormatted(), file, line, + LogTypes::LOG_LEVEL_TO_CHAR[(int)level], GetShortName(type), temp); for (auto listener_id : m_listener_ids) if (m_listeners[listener_id]) -- cgit v1.2.3