Skip to content

refactor: Make thread_system a required dependency (remove standalone mode) #216

Description

@kcenon

Overview

Change thread_system from an optional to a required dependency in logger_system, removing standalone mode entirely.

Background

Currently, logger_system has an optional dependency on thread_system and supports standalone mode. This causes:

  • Maintenance burden for two code paths
  • Complexity from conditional compilation (#ifdef)
  • Scattered test coverage

Since most higher-tier systems in unified_system already use thread_system, making it required has minimal practical impact.

Task List

Phase 1: CMake Cleanup (~1 hour)

  • CMakeLists.txt: Remove LOGGER_STANDALONE_MODE option
  • CMakeLists.txt: Make thread_system required (FATAL_ERROR if not found)
  • cmake/LoggerDependencies.cmake: Remove fallback logic
  • cmake/LoggerSystemConfig.cmake.in: Change to find_package(ThreadSystem REQUIRED)
  • tests/CMakeLists.txt: Remove standalone conditions

Phase 2: Remove Conditional Compilation (~1 hour)

Macros to remove:

  • LOGGER_STANDALONE
  • LOGGER_STANDALONE_MODE
  • USE_THREAD_SYSTEM (make always ON)

Header files to modify (8 files):

  • include/kcenon/logger/core/thread_integration_detector.h
  • include/kcenon/logger/backends/thread_system_backend.h
  • include/kcenon/logger/writers/async_writer.h
  • src/impl/di/di_container_factory.h
  • src/impl/monitoring/monitoring_factory.h
  • src/impl/monitoring/thread_system_monitor_adapter.h
  • src/impl/di/thread_system_di_adapter.h
  • src/impl/async/batch_processor.h

Phase 3: std::thread → worker_thread Migration (~2-3 hours)

Approach: Use dedicated worker_thread (long-running loops)

// Before
std::thread worker_thread_;
worker_thread_ = std::thread(&impl::process_loop, this);

// After
kcenon::thread::worker_thread worker_;
worker_.start([this]{ process_loop(); });

Source files to modify (3 files):

  • src/core/log_collector.cpp (lines 111, 247)
  • src/impl/writers/network_writer.cpp (lines 57, 61)
  • src/impl/async/batch_processor.cpp (line 48)

Phase 4: Test Updates (~30 min)

  • tests/integration/thread_system_integration_test.cpp: Remove GTEST_SKIP blocks
  • Remove standalone-related test cases

Phase 5: Build Script Cleanup (~30 min)

  • scripts/build.sh: Remove --standalone option

Phase 6: Verification (~1 hour)

  • Full build succeeds
  • Unit tests pass
  • Integration tests pass
  • CI/CD pipeline passes

Affected Files (19 total)

Category Count
CMake 5
Source 3
Headers 8
Tests 2
Scripts 1

Dependency Change

Before:
  logger_system
    ├─ common_system (REQUIRED)
    └─ thread_system (OPTIONAL)

After:
  logger_system
    ├─ common_system (REQUIRED)
    └─ thread_system (REQUIRED)

Expected Benefits

  • Reduced code complexity (~90% fewer conditional branches)
  • Single code path for easier maintenance
  • Simplified test coverage
  • Access to thread_system optimizations (Lock-free Queue, Hazard Pointers, etc.)

Breaking Changes

  • Standalone mode build no longer supported
  • logger_system cannot be used without thread_system

Estimated Time

Approximately 5-6 hours

Metadata

Metadata

Assignees

Labels

dependenciesDependency updates and managementenhancementNew feature or requestpriority:mediumMedium priority issuerefactorCode refactoring without changing functionalityrefactoringCode refactoring and improvementsthreadingThreading and concurrency

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions