Skip to content

Refactor/decouple drogon remove singleton#35

Merged
IronsDu merged 9 commits intomainfrom
refactor/decouple-drogon-remove-singleton
Apr 8, 2026
Merged

Refactor/decouple drogon remove singleton#35
IronsDu merged 9 commits intomainfrom
refactor/decouple-drogon-remove-singleton

Conversation

@IronsDu
Copy link
Copy Markdown
Owner

@IronsDu IronsDu commented Apr 7, 2026

No description provided.

IronsDu and others added 9 commits April 6, 2026 21:30
- Remove spdlog dependency: DefaultLogSink now uses std::cout/std::cerr
- Replace spdlog/fmt with C++20 std::format in log macros
- Add HttpServer abstraction interface (include/profiler/http_server.h)
- Remove singleton from LogManager, make it instance-owned
- Update log macros to use log_manager_ member instead of global singleton
- Update plan.md with full design document for the refactoring

Still TODO: ProfilerManager singleton removal, Drogon adapter,
web_server refactoring, CMake target split, example/test updates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Record completed tasks (spdlog removal, HttpServer interface,
LogManager de-singleton) and remaining tasks with specific
file-level change instructions for next development session.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove ProfilerManager singleton: delete getInstance(), make constructor
  public, use unique_ptr<LogManager> (PIMPL) for per-instance log config
- Create HttpServer abstraction: pure C++ interface (Request/Response structs)
  in include/profiler/http_server.h, no framework dependency
- Create Drogon adapter: src/backends/drogon/drogon_http_server.{h,cpp}
  implements HttpServer interface, only place that #includes <drogon/drogon.h>
- Rewrite web_server.cpp: all routes use HttpServer abstraction instead of
  Drogon directly, remove Json::Value dependency (manual JSON string building)
- Remove spdlog dependency: DefaultLogSink uses std::cout/std::cerr,
  log macros use std::format instead of fmt
- Split CMake targets: profiler_core (no Drogon) + profiler_web (optional,
  requires Drogon), add REMOTE_PROFILER_ENABLE_WEB option
- Update logger.h: global setSink/setLogLevel removed, now ProfilerManager
  instance methods
- Signal handler: lazy install on first captureAllThreadStacks() call
- Update example and tests for non-singleton API
- Remove spdlog from vcpkg.json

All 18 tests pass (LoggerTest: 7, FullFlowTest: 6, CPUProfileTest: 5).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the HttpServer interface pattern with a simpler, more flexible
design: ProfilerHttpHandlers provides framework-agnostic handler methods
that return HandlerResponse structs. Users with any web framework can
call handlers and wrap responses with their own request/response types.

- Add include/profiler/http_handlers.h (HandlerResponse + ProfilerHttpHandlers)
- Add src/http_handlers.cpp (all profiler endpoint business logic)
- Simplify web_server.cpp to a thin Drogon adapter
- Delete include/profiler/http_server.h and src/backends/drogon/
- Update example to use registerHttpHandlers(profiler) directly
- Move page handlers (WebResources) to profiler_web, data handlers to profiler_core

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace all getInstance() singleton references with local instances
- Add ProfilerHttpHandlers and HandlerResponse API documentation
- Add integration examples for any web framework (not just Drogon)
- Update setSink/setLogLevel as ProfilerManager instance methods
- Remove spdlog references (now uses std::cout/cerr)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rename web_server.h/cpp → profiler/drogon_adapter.h/src/drogon_adapter.cpp
- Rename registerHttpHandlers() → registerDrogonHandlers()
- Fix all getInstance() references in docs/examples → instance creation
- Fix profiler_lib references → profiler_core
- Update log_sink.h doc example to use instance method
- Update plan.md: remove outdated HttpServer/singleton/spdlog descriptions
- Update CMakeLists.txt install target for new header path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix test_cpu_profile.cpp: replace member function pointer cast with
  free function pointer (avoids -Werror=pmf-conversions)
- Apply clang-format-18 to profiler_manager.h/cpp, log_macros.h

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@IronsDu IronsDu merged commit 444b531 into main Apr 8, 2026
6 checks passed
@IronsDu IronsDu deleted the refactor/decouple-drogon-remove-singleton branch April 8, 2026 01:15
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