#pragma once #include #include #include #include #include #include #include // Niezbędne dla makra class AsyncLogger { public: // Tylko deklaracje funkcji static AsyncLogger& getInstance(); void log(const std::string& message); void start(); void stop(); // Usuwamy copy constructor i operator przypisania (Singleton) AsyncLogger(const AsyncLogger&) = delete; void operator=(const AsyncLogger&) = delete; private: AsyncLogger(); // Prywatny konstruktor ~AsyncLogger(); // Prywatny destruktor void processQueue(); std::thread loggingThread; std::mutex queueMutex; std::condition_variable cv; std::queue logQueue; std::atomic running; }; // Zmiana nazwy makra na GAME_LOG, aby uniknąć konfliktów (np. z bibliotekami matematycznymi) // Używamy pętli do...while(0), aby makro było bezpieczne w instrukcjach if/else #define GAME_LOG(stream_args) { \ std::ostringstream ss; \ ss << stream_args; \ AsyncLogger::getInstance().log(ss.str()); \ }