diff --git a/src/app/service_based_app.cpp b/src/app/service_based_app.cpp index 6b02c6c..815d274 100644 --- a/src/app/service_based_app.cpp +++ b/src/app/service_based_app.cpp @@ -1,5 +1,4 @@ #include "service_based_app.hpp" -#include "logging/logger.hpp" #include "events/event_bus.hpp" #include "services/interfaces/i_window_service.hpp" #include "services/interfaces/i_graphics_service.hpp" @@ -50,7 +49,12 @@ ServiceBasedApp::ServiceBasedApp(const std::filesystem::path& scriptPath) logger_->Info("ServiceBasedApp::ServiceBasedApp: constructor completed"); } catch (const std::exception& e) { - logging::Logger::GetInstance().Error("ServiceBasedApp::ServiceBasedApp: Failed to initialize ServiceBasedApp: " + std::string(e.what())); + if (logger_) { + logger_->Error("ServiceBasedApp::ServiceBasedApp: Failed to initialize ServiceBasedApp: " + std::string(e.what())); + } else { + // Fallback to console if logger not available + std::cerr << "ServiceBasedApp::ServiceBasedApp: Failed to initialize ServiceBasedApp: " << e.what() << std::endl; + } throw; } } diff --git a/src/main.cpp b/src/main.cpp index 9648ae7..fd1bf70 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -332,11 +332,12 @@ int main(int argc, char** argv) { throw std::runtime_error("Unable to determine platform config directory"); } } - sdl3cpp::app::ServiceBasedApp app(options.runtimeConfig.scriptPath); app.Run(); } catch (const std::runtime_error& e) { std::string errorMsg = e.what(); - sdl3cpp::logging::Logger::GetInstance().Error("Runtime error: " + errorMsg); + // For early errors before app is created, we can't use service logger + // Fall back to console output + std::cerr << "Runtime error: " << errorMsg << std::endl; // Check if this is a timeout/hang error - show simpler message for these bool isTimeoutError = errorMsg.find("timeout") != std::string::npos || @@ -362,7 +363,8 @@ int main(int argc, char** argv) { } return EXIT_FAILURE; } catch (const std::exception& e) { - sdl3cpp::logging::Logger::GetInstance().Error("Exception: " + std::string(e.what())); + // For early errors before app is created, we can't use service logger + std::cerr << "Exception: " << e.what() << std::endl; SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Application Error",