Skip to content

Commit

Permalink
Fix some log entries not being output with a newline.
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseTG committed Jun 18, 2024
1 parent a29c415 commit 93963f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/libretro/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 93963f6

Please sign in to comment.