Skip to content

feat(console): configurable output stream#118

Merged
NewYaroslav merged 4 commits into
mainfrom
feat/console-stream-routing
Jun 3, 2026
Merged

feat(console): configurable output stream#118
NewYaroslav merged 4 commits into
mainfrom
feat/console-stream-routing

Conversation

@NewYaroslav

Copy link
Copy Markdown
Owner

Summary

  • add ConsoleStreamKind/ConsoleStreamRoute types in a new ConsoleStreamRoute.hpp
  • extend ConsoleLogger with a primary std::ostream& plus an optional level-based routes table
  • default behavior (empty routes, std::cout) is preserved for existing users
  • Windows ANSI colors keep working for std::cout and std::cerr; any other stream disables colors
  • add LOGIT_ADD_CONSOLE_TO_STREAM* macros so consolix can target std::cerr with one macro
  • add console_logger_stream_test covering default cout, explicit ostream&, cerr routing, level-based cerr routing, and level-based custom stream routing

Verification

  • cmake -S . -B build-stream -G "MinGW Makefiles" -DLOGIT_CPP_BUILD_TESTS=ON
  • cmake --build build-stream --target console_logger_stream_test console_logger_dedicated_config_test -j2
  • ctest --test-dir build-stream -R console_logger --output-on-failure
  • cmake -S . -B build-stream-cxx11 -G "MinGW Makefiles" -DLOGIT_CPP_BUILD_TESTS=ON -DCMAKE_CXX_STANDARD=11
  • cmake --build build-stream-cxx11 --target console_logger_stream_test console_logger_dedicated_config_test -j2
  • ctest --test-dir build-stream-cxx11 -R console_logger --output-on-failure
  • git diff --check -- include/logit_cpp/logit/loggers/ConsoleStreamRoute.hpp include/logit_cpp/logit/loggers/ConsoleLogger.hpp include/logit_cpp/logit/log_macros.hpp tests/CMakeLists.txt tests/console_logger_stream_test.cpp

🤖 Generated with Claude Code

NewYaroslav and others added 4 commits June 3, 2026 01:00
Let ConsoleLogger target any std::ostream& and add an optional level-based routing table so callers can split regular output from diagnostics across cout, cerr, and any caller-provided stream without breaking the historical default behavior.

Constraint: Preserve default std::cout behavior and existing public API

Rejected: Built-in auto routing by level | would force a fixed severity policy users cannot tune

Confidence: high

Scope-risk: moderate

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Treat null custom streams as a no-op route, drop color writes into custom streams, trim the redundant config field copies in the dual-arg constructor, add static ConsoleStreamRoute helpers, rename TO_STREAM macros to STREAM, and cover sync and null-fallback paths in tests.

Constraint: Preserve public API and default std::cout behavior

Confidence: high

Scope-risk: narrow

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move ConsoleStreamRoute.hpp under loggers/ConsoleLogger/ and rely on the existing enums pull-in via the logger aggregator instead of an explicit ../enums.hpp include.

Constraint: Preserve public include path semantics through ConsoleLogger.hpp

Confidence: high

Scope-risk: narrow

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a small unit test for the to_cerr helper and mark ConsoleLogger::get_config() as const so it matches the rest of the read-only accessors.

Constraint: Preserve public API

Confidence: high

Scope-risk: narrow

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@NewYaroslav NewYaroslav merged commit c0ff37f into main Jun 3, 2026
13 checks passed
@NewYaroslav NewYaroslav deleted the feat/console-stream-routing branch June 3, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant