mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-24 13:44:58 +00:00
feat: Integrate ILogger into BulletPhysicsService and VulkanGuiService for improved logging
This commit is contained in:
@@ -236,7 +236,8 @@ void ServiceBasedApp::RegisterServices() {
|
||||
registry_.RegisterService<services::IGuiService, services::impl::VulkanGuiService>();
|
||||
|
||||
// Physics service
|
||||
registry_.RegisterService<services::IPhysicsService, services::impl::BulletPhysicsService>();
|
||||
registry_.RegisterService<services::IPhysicsService, services::impl::BulletPhysicsService>(
|
||||
registry_.GetService<services::ILogger>());
|
||||
|
||||
logger_->Trace("ServiceBasedApp", "RegisterServices", "", "Exiting");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#include "vulkan_gui_service.hpp"
|
||||
#include "../../logging/logger.hpp"
|
||||
#include "../interfaces/i_logger.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace sdl3cpp::services::impl {
|
||||
|
||||
VulkanGuiService::VulkanGuiService(std::shared_ptr<ILogger> 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<gui::GuiRenderer>(device, physicalDevice, format, resourcePath);
|
||||
initialized_ = true;
|
||||
|
||||
logging::Logger::GetInstance().Info("GUI service initialized");
|
||||
logger_->Info("GUI service initialized");
|
||||
}
|
||||
|
||||
void VulkanGuiService::PrepareFrame(const std::vector<GuiCommand>& commands,
|
||||
|
||||
@@ -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 <memory>
|
||||
@@ -16,7 +17,7 @@ namespace sdl3cpp::services::impl {
|
||||
class VulkanGuiService : public IGuiService,
|
||||
public di::IShutdownable {
|
||||
public:
|
||||
VulkanGuiService() = default;
|
||||
explicit VulkanGuiService(std::shared_ptr<ILogger> logger);
|
||||
~VulkanGuiService() override;
|
||||
|
||||
// IGuiService interface
|
||||
@@ -36,6 +37,7 @@ public:
|
||||
void Shutdown() noexcept override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ILogger> logger_;
|
||||
std::unique_ptr<gui::GuiRenderer> renderer_;
|
||||
bool initialized_ = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user