Skip to content

Refactor RedirectConsoleStream to use portable C++ stream buffer redirection (backport #776)#809

Merged
scpeters merged 1 commit intogz-common6from
mergify/bp/gz-common6/pr-776
Apr 30, 2026
Merged

Refactor RedirectConsoleStream to use portable C++ stream buffer redirection (backport #776)#809
scpeters merged 1 commit intogz-common6from
mergify/bp/gz-common6/pr-776

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Apr 30, 2026

🦟 Bug fix

Summary

This is instead of the unstable OS-level dup2 system call. This fixes reliability issues on Windows when combined with spdlog. Should hopefuly improve the flakiness of RedirectConsoleStream.InlineHelpers

The new implementation:

  • Redirects std::cout and std::cerr using std::ostream::rdbuf().
  • Adds a custom spdlog sink (RedirectConsoleSink) to capture logs emitted through Gazebo logging macros (gzmsg, gzerr, etc.).
  • Implements level-range filtering in the custom sink to maintain the expected separation between stdout-bound logs (Trace to Info) and stderr-bound logs (Warn to Critical).

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Generated-by: Gemini 3.0

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸


This is an automatic backport of pull request #776 done by [Mergify](https://mergify.com).

…direction (#776)

This is instead of the unstable OS-level `dup2` system call. This fixes reliability issues on Windows when combined with `spdlog`.

The new implementation:
- Redirects `std::cout` and `std::cerr` using `std::ostream::rdbuf()`.
- Adds a custom `spdlog` sink (`RedirectConsoleSink`) to capture logs emitted through Gazebo logging macros (`gzmsg`, `gzerr`, etc.).
- Implements level-range filtering in the custom sink to maintain the expected separation between stdout-bound logs (Trace to Info) and stderr-bound logs (Warn to Critical).

Generated-By: Gemini 3

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
(cherry picked from commit 94a7ce3)
@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development Apr 30, 2026
@scpeters scpeters merged commit 37fc6b8 into gz-common6 Apr 30, 2026
16 checks passed
@scpeters scpeters deleted the mergify/bp/gz-common6/pr-776 branch April 30, 2026 23:35
@github-project-automation github-project-automation Bot moved this from In review to Done in Core development Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants