diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2026-11-04 18:59:40 -0600 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2026-11-08 13:08:09 -0600 |
| commit | 055767399abab0eff6f55acbf480e54fcd83f6bd (patch) | |
| tree | 3c9ffa237f5cad87887e5e4eebb9e87395135270 /Source | |
| parent | d02fc5f4bb1733a0cfd45ee00b4a8e3ff2a53ca3 (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')
| -rw-r--r-- | Source/Core/AudioCommon/CubebUtils.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/Common/Logging/LogManager.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/Common/Logging/LogManager.h | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/Source/Core/AudioCommon/CubebUtils.cpp b/Source/Core/AudioCommon/CubebUtils.cpp index 0be4fdeb81..67a2c3a824 100644 --- a/Source/Core/AudioCommon/CubebUtils.cpp +++ b/Source/Core/AudioCommon/CubebUtils.cpp @@ -39,7 +39,7 @@ static void LogCallback(const char* format, ...) const std::string message = StringFromFormatV(adapted_format.c_str(), args); va_end(args); - instance->LogWithFullPath(log_level, log_type, filename, lineno, message.c_str()); + instance->LogWithFullPath(log_level, log_type, filename, lineno, message); } static void DestroyContext(cubeb* ctx) 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; |
