Fix some log entries not being output with a newline.

This commit is contained in:
Jesse Talavera 2024-06-18 17:10:45 -04:00
parent a29c41595a
commit 93963f62c3
2 changed files with 10 additions and 5 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0),
and this project roughly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Fixed some log entries not being output with a newline.
## [1.1.3] - 2024-06-14
### Fixed

View File

@ -300,13 +300,12 @@ constexpr uint32_t GetLogColor(retro_log_level level) noexcept {
void retro::fmt_log(retro_log_level level, fmt::string_view fmt, fmt::format_args args) noexcept {
fmt::basic_memory_buffer<char, 1024> buffer;
fmt::vformat_to(std::back_inserter(buffer), fmt, args);
// We can't pass the va_list directly to the libretro callback,
// so we have to construct the string and print that
if (buffer[buffer.size() - 1] == '\n')
buffer[buffer.size() - 1] = '\0';
if (buffer[buffer.size() - 1] != '\n')
// If the string doesn't end with a newline...
buffer.push_back('\n');
buffer.push_back('\n');
// vformat_to doesn't append a null terminator, so we have to do it ourselves
buffer.push_back('\0');
if (_log) {