Skip to content

Add SetConsoleColorMode to Logger#205

Open
BhuvanB404 wants to merge 1 commit intogazebosim:gz-utils4from
BhuvanB404:gz-utils4
Open

Add SetConsoleColorMode to Logger#205
BhuvanB404 wants to merge 1 commit intogazebosim:gz-utils4from
BhuvanB404:gz-utils4

Conversation

@BhuvanB404
Copy link

🎉 New feature

This exposes control over the color output mode of the console sink,
allowing callers to override spdlog's automatic terminal detection.

Required by gazebosim/gz-common#792
Related: gazebosim/gz-common#611

Summary

Test it

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the feature
  • Added tests
  • Added example and/or tutorial
  • 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)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • 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.)

Exposes color_mode control on the console sink to allow callers
to override spdlog's automatic color detection.
Required by gazebosim/gz-common#792
Related: gazebosim/gz-common#611

Signed-off-by: BhuvanB <bhuvanb1408@gmail.com>
@BhuvanB404 BhuvanB404 requested a review from azeey as a code owner March 6, 2026 07:59
Copilot AI review requested due to automatic review settings March 6, 2026 07:59
@github-actions github-actions bot added the 🪵 jetty Gazebo Jetty label Mar 6, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new public Logger API to control the console sink’s color output mode, enabling callers to override spdlog’s automatic terminal color detection (as requested by downstream usage in gz-common).

Changes:

  • Add Logger::SetConsoleColorMode(spdlog::color_mode) to the public header.
  • Implement Logger::SetConsoleColorMode to forward the requested mode to the internal console sink.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
log/src/Logger.cc Implements SetConsoleColorMode by applying the mode to the console sink.
log/include/gz/utils/log/Logger.hh Declares the new public API and documents the parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +137 to +142
void Logger::SetConsoleColorMode(spdlog::color_mode _mode)
{
if (this->dataPtr->consoleSink)
{
this->dataPtr->consoleSink->set_color_mode(_mode);
}
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetConsoleColorMode introduces new user-facing behavior (overriding spdlog’s terminal color auto-detection), but there’s no corresponding unit test exercising this API. Since log/src/Logger_TEST.cc already covers SetConsoleSinkLevel, please add a similar test that calls SetConsoleColorMode and asserts the expected effect (e.g., color codes are suppressed when set to never, or at minimum that calling it changes the underlying sink state / does not emit ANSI codes).

Copilot uses AI. Check for mistakes.
@azeey
Copy link
Contributor

azeey commented Mar 6, 2026

See gazebosim/gz-common#792 (review). In light of that, I don't think we'll need this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪵 jetty Gazebo Jetty

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

3 participants