Add SetConsoleColorMode to Logger#205
Conversation
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>
There was a problem hiding this comment.
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::SetConsoleColorModeto 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.
| void Logger::SetConsoleColorMode(spdlog::color_mode _mode) | ||
| { | ||
| if (this->dataPtr->consoleSink) | ||
| { | ||
| this->dataPtr->consoleSink->set_color_mode(_mode); | ||
| } |
There was a problem hiding this comment.
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).
|
See gazebosim/gz-common#792 (review). In light of that, I don't think we'll need this change. |
🎉 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
codecheckpassed (See contributing)