From 8ff88de33b305dbf2cb6e08d0d16e41a4695d2d3 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Sun, 4 Jan 2026 14:42:03 +0000 Subject: [PATCH] feat: Integrate ILogger into BulletPhysicsService and VulkanGuiService for improved logging --- src/app/service_based_app.cpp | 3 ++- src/services/impl/bullet_physics_service.cpp | 18 +++++++++--------- src/services/impl/vulkan_gui_service.cpp | 10 +++++++--- src/services/impl/vulkan_gui_service.hpp | 4 +++- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/app/service_based_app.cpp b/src/app/service_based_app.cpp index c6ddebf..1da00b2 100644 --- a/src/app/service_based_app.cpp +++ b/src/app/service_based_app.cpp @@ -236,7 +236,8 @@ void ServiceBasedApp::RegisterServices() { registry_.RegisterService(); // Physics service - registry_.RegisterService(); + registry_.RegisterService( + registry_.GetService()); logger_->Trace("ServiceBasedApp", "RegisterServices", "", "Exiting"); } diff --git a/src/services/impl/bullet_physics_service.cpp b/src/services/impl/bullet_physics_service.cpp index f3cf313..f44b6cf 100644 --- a/src/services/impl/bullet_physics_service.cpp +++ b/src/services/impl/bullet_physics_service.cpp @@ -93,34 +93,34 @@ bool BulletPhysicsService::GetTransform(const std::string& name, btTransform& ou } bool BulletPhysicsService::SetTransform(const std::string& name, const btTransform& transform) { - logging::TraceGuard trace; + logger_->TraceFunction(__func__); // PhysicsBridge doesn't support setting transforms in current implementation - logging::Logger::GetInstance().Warn("SetTransform not supported by PhysicsBridge"); + logger_->Warn("SetTransform not supported by PhysicsBridge"); return false; } bool BulletPhysicsService::ApplyForce(const std::string& name, const btVector3& force) { - logging::TraceGuard trace; + logger_->TraceFunction(__func__); // PhysicsBridge doesn't support applying forces in current implementation - logging::Logger::GetInstance().Warn("ApplyForce not supported by PhysicsBridge"); + logger_->Warn("ApplyForce not supported by PhysicsBridge"); return false; } bool BulletPhysicsService::ApplyImpulse(const std::string& name, const btVector3& impulse) { - logging::TraceGuard trace; + logger_->TraceFunction(__func__); // PhysicsBridge doesn't support applying impulses in current implementation - logging::Logger::GetInstance().Warn("ApplyImpulse not supported by PhysicsBridge"); + logger_->Warn("ApplyImpulse not supported by PhysicsBridge"); return false; } bool BulletPhysicsService::SetLinearVelocity(const std::string& name, const btVector3& velocity) { - logging::TraceGuard trace; + logger_->TraceFunction(__func__); // PhysicsBridge doesn't support setting velocity in current implementation - logging::Logger::GetInstance().Warn("SetLinearVelocity not supported by PhysicsBridge"); + logger_->Warn("SetLinearVelocity not supported by PhysicsBridge"); return false; } @@ -131,7 +131,7 @@ size_t BulletPhysicsService::GetBodyCount() const { } void BulletPhysicsService::Clear() { - logging::TraceGuard trace; + logger_->TraceFunction(__func__); if (!physicsBridge_) { return; diff --git a/src/services/impl/vulkan_gui_service.cpp b/src/services/impl/vulkan_gui_service.cpp index d649c3b..bfa44cb 100644 --- a/src/services/impl/vulkan_gui_service.cpp +++ b/src/services/impl/vulkan_gui_service.cpp @@ -1,9 +1,13 @@ #include "vulkan_gui_service.hpp" -#include "../../logging/logger.hpp" +#include "../interfaces/i_logger.hpp" #include namespace sdl3cpp::services::impl { +VulkanGuiService::VulkanGuiService(std::shared_ptr logger) + : logger_(std::move(logger)) { +} + VulkanGuiService::~VulkanGuiService() { if (initialized_) { Shutdown(); @@ -14,7 +18,7 @@ void VulkanGuiService::Initialize(VkDevice device, VkPhysicalDevice physicalDevice, VkFormat format, const std::filesystem::path& resourcePath) { - logging::TraceGuard trace; + logger_->TraceFunction(__func__); if (initialized_) { return; @@ -23,7 +27,7 @@ void VulkanGuiService::Initialize(VkDevice device, renderer_ = std::make_unique(device, physicalDevice, format, resourcePath); initialized_ = true; - logging::Logger::GetInstance().Info("GUI service initialized"); + logger_->Info("GUI service initialized"); } void VulkanGuiService::PrepareFrame(const std::vector& commands, diff --git a/src/services/impl/vulkan_gui_service.hpp b/src/services/impl/vulkan_gui_service.hpp index 36b3b0c..a3e2d93 100644 --- a/src/services/impl/vulkan_gui_service.hpp +++ b/src/services/impl/vulkan_gui_service.hpp @@ -1,6 +1,7 @@ #pragma once #include "../interfaces/i_gui_service.hpp" +#include "../interfaces/i_logger.hpp" #include "../../gui/gui_renderer.hpp" #include "../../di/lifecycle.hpp" #include @@ -16,7 +17,7 @@ namespace sdl3cpp::services::impl { class VulkanGuiService : public IGuiService, public di::IShutdownable { public: - VulkanGuiService() = default; + explicit VulkanGuiService(std::shared_ptr logger); ~VulkanGuiService() override; // IGuiService interface @@ -36,6 +37,7 @@ public: void Shutdown() noexcept override; private: + std::shared_ptr logger_; std::unique_ptr renderer_; bool initialized_ = false; };