Skip to content

feat: integrate logger_system for structured logging#6

Merged
kcenon merged 7 commits into
mainfrom
feature/logger-system-integration
Sep 21, 2025
Merged

feat: integrate logger_system for structured logging#6
kcenon merged 7 commits into
mainfrom
feature/logger-system-integration

Conversation

@kcenon

@kcenon kcenon commented Sep 20, 2025

Copy link
Copy Markdown
Owner

Summary

  • Integrated logger_system to replace all std::cout/cerr usage throughout network_system
  • Added conditional compilation support with BUILD_WITH_LOGGER_SYSTEM CMake option
  • Implemented fallback basic_logger for standalone operation

Changes

Implementation

  • Created logger_integration.h and logger_integration.cpp with logger interface
  • Implemented two logger adapters:
    • basic_logger: Console output for standalone operation
    • logger_system_adapter: Integration with external logger_system when available
  • Added convenient logging macros: NETWORK_LOG_TRACE, DEBUG, INFO, WARN, ERROR, FATAL

Code Migration

  • Replaced all std::cout/cerr calls with structured logging macros in:
    • messaging_client.cpp
    • messaging_server.cpp
    • messaging_session.cpp
    • send_coroutine.cpp
    • pipeline.cpp
  • Removed unnecessary iostream includes where possible

Build System

  • Added BUILD_WITH_LOGGER_SYSTEM option to CMakeLists.txt
  • Configured automatic detection of logger_system in ../logger_system directory
  • Set up conditional compilation flags

Documentation

  • Updated README.md with logger integration information
  • Added logger system to optional dependencies
  • Created comprehensive INTEGRATION.md guide
  • Updated CHANGELOG.md with detailed changes

Features

  • Log Levels: TRACE, DEBUG, INFO, WARN, ERROR, FATAL
  • Source Tracking: Automatic file, line, and function recording
  • Timestamps: Millisecond precision formatting
  • Performance: Minimal overhead with compile-time log level checking
  • Flexibility: Works with or without external logger_system

Test Plan

  • Build without logger_system (BUILD_WITH_LOGGER_SYSTEM=OFF)
  • Verify basic_logger console output works correctly
  • Test all log levels produce expected output
  • Confirm no compilation errors or warnings
  • Build with logger_system (BUILD_WITH_LOGGER_SYSTEM=ON)
  • Verify logger_system_adapter integration
  • Run existing test suite to ensure no regressions
  • Performance benchmarks to verify minimal impact

Breaking Changes

None - All changes are backward compatible

Related Issues

  • Part of network_system modularization effort
  • Preparation for monitoring_system integration

Replace std::cout/cerr with structured logging throughout network_system.
This provides better debugging capabilities, log level filtering, and
prepares for future monitoring integration.

Changes:
- Add logger_integration interface with basic_logger and logger_system_adapter
- Replace initial std::cout/cerr calls with NETWORK_LOG macros
- Add BUILD_WITH_LOGGER_SYSTEM CMake option for conditional compilation
- Implement timestamp and source location tracking
- Add logger_integration.h to architecture diagram in README
- Include BUILD_WITH_LOGGER_SYSTEM in build configuration examples
- Document logger system as optional dependency
- Add comprehensive logger integration section to CHANGELOG
- Create new INTEGRATION.md guide with detailed logger usage
- Document all integration options and configuration methods
Update include paths from "network/" to "network_system/" in legacy
compatibility files to maintain consistency with the new project structure.
This ensures proper header resolution when building the project.

Changed files in core/, session/, and internal/ directories to use
the correct project-wide header paths while maintaining network_module
namespace for backward compatibility.
- Add explicit underlying type (int) to log_level enum class
- Use std::atomic<int> instead of std::atomic<log_level> for portability
- Add explicit casts when comparing/assigning log levels
- Include <atomic> header for std::atomic support

This fixes compilation errors on GCC/Linux where std::atomic
requires complete type information for enum classes.
@github-actions

Copy link
Copy Markdown
Contributor

Performance Comparison

Base Branch Results

Throughput: inf msg/s
Throughput: inf msg/s
Throughput: 333333.33 msg/s
Throughput: 6369.43 msg/s
Throughput: 13157.89 msg/s
Throughput: 55555.56 msg/s
Throughput: 55555.56 msg/s
Throughput: 5000000.00 msg/s
Throughput: 6250000.00 msg/s

PR Branch Results

Throughput: inf msg/s
Throughput: inf msg/s
Throughput: 333333.33 msg/s
Throughput: 6369.43 msg/s
Throughput: 13157.89 msg/s
Throughput: 58823.53 msg/s
Throughput: 55248.62 msg/s
Throughput: 5000000.00 msg/s
Throughput: 6250000.00 msg/s

- Update thread_system to use kcenon::thread namespace and new headers
- Fix messaging_bridge to use kcenon::thread::thread_pool instead of thread_system::thread_pool
- Add thread_system and logger_system include paths to all test targets
- Enable proper linking of updated thread_base and LoggerSystem libraries
- Remove obsolete Makefile in favor of CMake build system

All tests now build successfully with updated dependencies.
- Ignore Unix/macOS test executables without extensions
- Prevent test binaries from being accidentally committed
- Remove binary executables stress_test and test_e2e from version control
- These should be generated during build, not tracked in repository
@github-actions

Copy link
Copy Markdown
Contributor

Performance Comparison

Base Branch Results

Throughput: 10000000.00 msg/s
Throughput: inf msg/s
Throughput: 333333.33 msg/s
Throughput: 6369.43 msg/s
Throughput: 13157.89 msg/s
Throughput: 58823.53 msg/s
Throughput: 57471.26 msg/s
Throughput: 5000000.00 msg/s
Throughput: 6250000.00 msg/s

PR Branch Results

Throughput: inf msg/s
Throughput: inf msg/s
Throughput: 500000.00 msg/s
Throughput: 6369.43 msg/s
Throughput: 13157.89 msg/s
Throughput: 55555.56 msg/s
Throughput: 56497.18 msg/s
Throughput: 5000000.00 msg/s
Throughput: 6250000.00 msg/s

@kcenon kcenon merged commit b22e827 into main Sep 21, 2025
18 checks passed
@kcenon kcenon deleted the feature/logger-system-integration branch September 21, 2025 01:44
kcenon added a commit that referenced this pull request Apr 13, 2026
* feat(logging): integrate logger_system for centralized logging

Replace std::cout/cerr with structured logging throughout network_system.
This provides better debugging capabilities, log level filtering, and
prepares for future monitoring integration.

Changes:
- Add logger_integration interface with basic_logger and logger_system_adapter
- Replace initial std::cout/cerr calls with NETWORK_LOG macros
- Add BUILD_WITH_LOGGER_SYSTEM CMake option for conditional compilation
- Implement timestamp and source location tracking

* docs: update documentation for logger system integration

- Add logger_integration.h to architecture diagram in README
- Include BUILD_WITH_LOGGER_SYSTEM in build configuration examples
- Document logger system as optional dependency
- Add comprehensive logger integration section to CHANGELOG
- Create new INTEGRATION.md guide with detailed logger usage
- Document all integration options and configuration methods

* fix: correct header include paths in legacy files

Update include paths from "network/" to "network_system/" in legacy
compatibility files to maintain consistency with the new project structure.
This ensures proper header resolution when building the project.

Changed files in core/, session/, and internal/ directories to use
the correct project-wide header paths while maintaining network_module
namespace for backward compatibility.

* fix: resolve atomic log_level compilation issue on Linux

- Add explicit underlying type (int) to log_level enum class
- Use std::atomic<int> instead of std::atomic<log_level> for portability
- Add explicit casts when comparing/assigning log levels
- Include <atomic> header for std::atomic support

This fixes compilation errors on GCC/Linux where std::atomic
requires complete type information for enum classes.

* feat(integration): update thread_system and logger_system integration

- Update thread_system to use kcenon::thread namespace and new headers
- Fix messaging_bridge to use kcenon::thread::thread_pool instead of thread_system::thread_pool
- Add thread_system and logger_system include paths to all test targets
- Enable proper linking of updated thread_base and LoggerSystem libraries
- Remove obsolete Makefile in favor of CMake build system

All tests now build successfully with updated dependencies.

* chore(build): add test executables to .gitignore

- Ignore Unix/macOS test executables without extensions
- Prevent test binaries from being accidentally committed

* chore(build): remove test executables from git tracking

- Remove binary executables stress_test and test_e2e from version control
- These should be generated during build, not tracked in repository
kcenon added a commit that referenced this pull request May 8, 2026
Round-2 reviewer feedback (M1, Issue #1115): the Round-6 direct-call
refactor changed the semantics of ServerUnknownFrameTypeIsHandled-
WithoutCrashing — the original wire-level test sent a raw frame header
with type=0xFF, exercising EITHER the process_frame default switch arm
OR the run_io parse-error path (RFC 7540 §5.5 unknown-type discard).

Direct invocation through Http2ClientTestAccess::process_frame cannot
construct a frame instance with an undefined type because frame::parse
rejects unknown types upstream of process_frame. The TEST_F now passes
a null unique_ptr<frame>, which exercises the null-pointer defensive
guard at src/protocols/http2/http2_client.cpp:620 — a complementary
arm, not the unknown-type dispatch.

The unknown-type wire path remains covered by
MalformedServerSettingsTypeByteTriggersConnectTimeout (which lives on
the multiplier scaffold and uses frame_injector to corrupt the type
byte on a real socket).

Renamed in place (no new TEST_F added, AC #6 preserved):
- ServerUnknownFrameTypeIsHandledWithoutCrashing
+ ProcessFrameNullPointerGuardReturnsInvalidArgument

The implementation comment block is rewritten to explain the semantic
shift so future maintainers see why the rename happened.
kcenon added a commit that referenced this pull request May 8, 2026
Round-2 reviewer feedback (M1, Issue #1115): the Round-6 direct-call
refactor changed the semantics of ServerUnknownFrameTypeIsHandled-
WithoutCrashing — the original wire-level test sent a raw frame header
with type=0xFF, exercising EITHER the process_frame default switch arm
OR the run_io parse-error path (RFC 7540 §5.5 unknown-type discard).

Direct invocation through Http2ClientTestAccess::process_frame cannot
construct a frame instance with an undefined type because frame::parse
rejects unknown types upstream of process_frame. The TEST_F now passes
a null unique_ptr<frame>, which exercises the null-pointer defensive
guard at src/protocols/http2/http2_client.cpp:620 — a complementary
arm, not the unknown-type dispatch.

The unknown-type wire path remains covered by
MalformedServerSettingsTypeByteTriggersConnectTimeout (which lives on
the multiplier scaffold and uses frame_injector to corrupt the type
byte on a real socket).

Renamed in place (no new TEST_F added, AC #6 preserved):
- ServerUnknownFrameTypeIsHandledWithoutCrashing
+ ProcessFrameNullPointerGuardReturnsInvalidArgument

The implementation comment block is rewritten to explain the semantic
shift so future maintainers see why the rename happened.
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