summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2026-11-04 18:59:40 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2026-11-08 13:08:09 -0600
commit055767399abab0eff6f55acbf480e54fcd83f6bd (patch)
tree3c9ffa237f5cad87887e5e4eebb9e87395135270 /Source/Core/Common
parentd02fc5f4bb1733a0cfd45ee00b4a8e3ff2a53ca3 (diff)
Common/Logging/LogManager: Pass string_view instead of char* to give fmt string length awareness without having to perform strlen calls.
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Logging/LogManager.cpp7
-rw-r--r--Source/Core/Common/Logging/LogManager.h4
2 files changed, 6 insertions, 5 deletions
diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp
index ae3ea6a66c..0bc51bfa5b 100644
--- a/Source/Core/Common/Logging/LogManager.cpp
+++ b/Source/Core/Common/Logging/LogManager.cpp
@@ -69,7 +69,7 @@ void GenericLogFmtImpl(LogLevel level, LogType type, const char* file, int line,
return;
const auto message = fmt::vformat(format, args);
- instance->Log(level, type, file, line, message.c_str());
+ instance->Log(level, type, file, line, message);
}
static consteval size_t GetPathCutOffPoint()
@@ -191,7 +191,8 @@ void LogManager::SaveSettings()
Config::Save();
}
-void LogManager::Log(LogLevel level, LogType type, const char* file, int line, const char* message)
+void LogManager::Log(LogLevel level, LogType type, const char* file, int line,
+ std::string_view message)
{
LogWithFullPath(level, type, file + GetPathCutOffPoint(), line, message);
}
@@ -209,7 +210,7 @@ std::string LogManager::GetTimestamp()
}
void LogManager::LogWithFullPath(LogLevel level, LogType type, const char* file, int line,
- const char* message)
+ std::string_view message)
{
const std::string msg =
fmt::format("{} {}:{} {}[{}]: {}\n", GetTimestamp(), file, line,
diff --git a/Source/Core/Common/Logging/LogManager.h b/Source/Core/Common/Logging/LogManager.h
index 7e145b0da1..060488a98f 100644
--- a/Source/Core/Common/Logging/LogManager.h
+++ b/Source/Core/Common/Logging/LogManager.h
@@ -56,9 +56,9 @@ public:
static void Init();
static void Shutdown();
- void Log(LogLevel level, LogType type, const char* file, int line, const char* message);
+ void Log(LogLevel level, LogType type, const char* file, int line, std::string_view message);
void LogWithFullPath(LogLevel level, LogType type, const char* file, int line,
- const char* message);
+ std::string_view message);
// Use this function instead of LOGGER_VERBOSITY to determine which logs should be printed.
LogLevel GetEffectiveLogLevel() const;