Repository navigation
fix: Fixed the console logs flushing logic. - #18
Conversation
- Deleted .vscode/settings.json to eliminate outdated IDE settings. - Removed unused logo files: vertexnova_logo_medallion_banner.png, vertexnova_logo_medallion_banner.svg, and vertexnova_logo_medallion_with_text.png to clean up the assets directory.
- Updated ConsoleLogSink to direct error and fatal logs to stderr, while other logs go to stdout. - Ensured immediate visibility of logs by flushing the output streams after each write. - Refactored test setup to capture both stdout and stderr for comprehensive log testing.
- Renamed CoutRedirect to StreamRedirect to better reflect functionality for both std::cout and std::cerr. - Updated test setup to capture both stdout and stderr outputs. - Introduced clearCapturedOutput() method for resetting captured output, improving test clarity and maintainability. - Refactored output verification in tests to utilize capturedConsoleOutput() for consistency.
…r Google Test - Updated vnecmake and vnecommon submodule references to the latest commits. - Enhanced CMakeLists.txt to allow optional use of system-installed Google Test, with fallback to bundled version if not found, improving flexibility in test environment setup.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThis PR routes error-and-higher logs to stderr and other levels to stdout; removes per-call flushing from log (flush() now flushes both streams); adds a StreamRedirect RAII helper for tests to capture both streams; updates tests and tests/CMakeLists.txt for dual-stream capture and flexible GTest resolution. ChangesConsole Logging stderr/stdout Split and Test Adaptation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates console logging behavior and related tests, while also changing test dependency setup and removing repository assets/settings.
Changes:
- Routes error/fatal console logs to
stderr, flushes console streams, and updates tests to capture bothstdoutandstderr. - Adds a CMake option for system Google Test with bundled fallback and sets the test working directory.
- Removes a VS Code settings file and an SVG logo asset.
Reviewed changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/vertexnova/logging/core/console_log_sink.cpp |
Updates console output routing and flushing behavior. |
tests/core/console_log_sink_test.cpp |
Adjusts console sink tests to capture stdout/stderr. |
tests/logging_system_test.cpp |
Updates logging system tests to capture both console streams. |
tests/core/text_color_test.cpp |
Changes self-assignment test to avoid direct self-assignment syntax. |
tests/CMakeLists.txt |
Adds configurable Google Test selection and test working directory. |
.vscode/settings.json |
Removes workspace settings. |
icons/vertexnova_logo_medallion_banner.svg |
Removes SVG logo asset. |
Comments suppressed due to low confidence (1)
.vscode/settings.json:1
- Deleting the repository VS Code workspace settings is outside the scope described by the PR title/description. Please update the PR description with the rationale for removing these shared development settings, or revert this file deletion if it was not intended.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
tests/logging_system_test.cpp (1)
36-51: ⚡ Quick winReplace raw owning pointers with
std::unique_ptr.The test fixture uses raw owning pointers with manual
new/delete, which violates RAII best practices. As per coding guidelines, preferstd::unique_ptrfor ownership to ensure automatic cleanup and exception safety.♻️ Proposed refactor
void SetUp() override { - cout_redirect_ = new StreamRedirect(std::cout, cout_buffer_.rdbuf()); - cerr_redirect_ = new StreamRedirect(std::cerr, cerr_buffer_.rdbuf()); + cout_redirect_ = std::make_unique<StreamRedirect>(std::cout, cout_buffer_.rdbuf()); + cerr_redirect_ = std::make_unique<StreamRedirect>(std::cerr, cerr_buffer_.rdbuf()); } void TearDown() override { // Remove the test directory and clean up try { std::filesystem::remove_all(kTestDir); } catch (const std::exception& e) { std::cerr << "Exception during TearDown(): " << e.what() << std::endl; } - delete cout_redirect_; - delete cerr_redirect_; + cout_redirect_.reset(); + cerr_redirect_.reset(); }protected: std::stringstream cout_buffer_; std::stringstream cerr_buffer_; - StreamRedirect* cout_redirect_ = nullptr; - StreamRedirect* cerr_redirect_ = nullptr; + std::unique_ptr<StreamRedirect> cout_redirect_; + std::unique_ptr<StreamRedirect> cerr_redirect_; };Also applies to: 63-67
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/logging_system_test.cpp` around lines 36 - 51, Replace the raw owning pointers cout_redirect_ and cerr_redirect_ in the test fixture with std::unique_ptr to enforce RAII: change their declarations to std::unique_ptr<StreamRedirect>, initialize them in SetUp() using std::make_unique<StreamRedirect>(...) instead of new, and remove the explicit delete calls from TearDown(); ensure StreamRedirect construction and destruction behavior remains the same and update any other occurrences (e.g., lines around the other fixture use at 63-67) to use the unique_ptr API (->) where needed.tests/CMakeLists.txt (1)
30-30: ⚡ Quick winRemove unused variable.
The variable
_vne_use_bundled_gtestis set but never used in the rest of the file. This is dead code and should be removed.🧹 Proposed fix
-set(_vne_use_bundled_gtest FALSE) - if(VNE_USE_SYSTEM_GTEST)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/CMakeLists.txt` at line 30, Remove the dead CMake variable assignment for _vne_use_bundled_gtest by deleting the line set(_vne_use_bundled_gtest FALSE); confirm there are no other references to _vne_use_bundled_gtest elsewhere and if the intent was to expose a configurable option, replace it with an option(...) or set a documented cache variable instead of the unused local set call.tests/core/console_log_sink_test.cpp (1)
38-49: ⚡ Quick winReplace raw owning pointers with
std::unique_ptr.The test fixture uses raw owning pointers with manual
new/delete, which violates RAII best practices and increases risk if exceptions occur during setup. As per coding guidelines, preferstd::unique_ptrfor ownership.♻️ Proposed refactor
void SetUp() override { // Force colors on for testing (tests run without TTY) log::setColorEnabled(true); - cout_redirect_ = new StreamRedirect(std::cout, cout_buffer_.rdbuf()); - cerr_redirect_ = new StreamRedirect(std::cerr, cerr_buffer_.rdbuf()); + cout_redirect_ = std::make_unique<StreamRedirect>(std::cout, cout_buffer_.rdbuf()); + cerr_redirect_ = std::make_unique<StreamRedirect>(std::cerr, cerr_buffer_.rdbuf()); } void TearDown() override { - delete cout_redirect_; - delete cerr_redirect_; + cout_redirect_.reset(); + cerr_redirect_.reset(); log::setColorEnabled(true); }protected: std::stringstream cout_buffer_; std::stringstream cerr_buffer_; - StreamRedirect* cout_redirect_ = nullptr; - StreamRedirect* cerr_redirect_ = nullptr; + std::unique_ptr<StreamRedirect> cout_redirect_; + std::unique_ptr<StreamRedirect> cerr_redirect_; };Also applies to: 56-60
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/core/console_log_sink_test.cpp` around lines 38 - 49, Replace the raw owning pointers cout_redirect_ and cerr_redirect_ with std::unique_ptr<StreamRedirect>; update their declarations accordingly, construct them with std::make_unique in SetUp (using cout_buffer_.rdbuf() and cerr_buffer_.rdbuf()), and remove the manual delete calls in TearDown (allow unique_ptr to destroy automatically, or call reset() if explicit release is desired); keep calls to log::setColorEnabled(true) and ensure StreamRedirect usage and members (cout_buffer_, cerr_buffer_) remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/logging_system_test.cpp`:
- Around line 17-29: Extract the duplicated StreamRedirect RAII class into a
single shared test header (e.g., create tests/stream_redirect.h) and replace the
inline definitions in console_log_sink_test.cpp and logging_system_test.cpp with
an `#include` of that header; ensure the new header contains the StreamRedirect
definition (constructor, destructor, private members) with proper include guards
or pragma once and the same behavior, then remove the duplicate class
declarations from both test files and update their includes to reference the
shared header so they reuse the single implementation.
- Line 46: The TearDown() exception handler currently writes to std::cerr while
the test framework has redirected std::cerr, so the message will be captured
instead of appearing on the real console; update the handler in TearDown() to
write the error directly to the OS stderr (e.g., use a low-level write to
STDERR_FILENO or call fprintf(stderr, ...) after restoring the original stream)
and include e.what() in that write so the message goes to the real terminal
rather than the test buffer.
---
Nitpick comments:
In `@tests/CMakeLists.txt`:
- Line 30: Remove the dead CMake variable assignment for _vne_use_bundled_gtest
by deleting the line set(_vne_use_bundled_gtest FALSE); confirm there are no
other references to _vne_use_bundled_gtest elsewhere and if the intent was to
expose a configurable option, replace it with an option(...) or set a documented
cache variable instead of the unused local set call.
In `@tests/core/console_log_sink_test.cpp`:
- Around line 38-49: Replace the raw owning pointers cout_redirect_ and
cerr_redirect_ with std::unique_ptr<StreamRedirect>; update their declarations
accordingly, construct them with std::make_unique in SetUp (using
cout_buffer_.rdbuf() and cerr_buffer_.rdbuf()), and remove the manual delete
calls in TearDown (allow unique_ptr to destroy automatically, or call reset() if
explicit release is desired); keep calls to log::setColorEnabled(true) and
ensure StreamRedirect usage and members (cout_buffer_, cerr_buffer_) remain
unchanged.
In `@tests/logging_system_test.cpp`:
- Around line 36-51: Replace the raw owning pointers cout_redirect_ and
cerr_redirect_ in the test fixture with std::unique_ptr to enforce RAII: change
their declarations to std::unique_ptr<StreamRedirect>, initialize them in
SetUp() using std::make_unique<StreamRedirect>(...) instead of new, and remove
the explicit delete calls from TearDown(); ensure StreamRedirect construction
and destruction behavior remains the same and update any other occurrences
(e.g., lines around the other fixture use at 63-67) to use the unique_ptr API
(->) where needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c85a09dc-924e-4240-9509-85071faa83c0
⛔ Files ignored due to path filters (3)
icons/vertexnova_logo_medallion_banner.pngis excluded by!**/*.pngicons/vertexnova_logo_medallion_banner.svgis excluded by!**/*.svgicons/vertexnova_logo_medallion_with_text.pngis excluded by!**/*.png
📒 Files selected for processing (8)
.vscode/settings.jsoncmake/vnecmakedeps/internal/vnecommonsrc/vertexnova/logging/core/console_log_sink.cpptests/CMakeLists.txttests/core/console_log_sink_test.cpptests/core/text_color_test.cpptests/logging_system_test.cpp
💤 Files with no reviewable changes (1)
- .vscode/settings.json
…ging functionality - Removed direct flushing of stdout and stderr in ConsoleLogSink, delegating flushing to ConsoleLogSink::flush() for better control. - Introduced a new StreamRedirect class for capturing console output, replacing raw pointers with std::unique_ptr for improved memory management. - Updated test setup and teardown processes to utilize the new StreamRedirect class, enhancing clarity and safety in output redirection.
…s.txt - Deleted the variable setting for using bundled Google Test, streamlining the CMake configuration for test dependencies.
Summary by CodeRabbit
Bug Fixes
Chores