From 74d15274124a1ac7a2f5b9c35de9dbf4655b9ce9 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 12 Feb 2023 13:44:29 +0300 Subject: [PATCH 1/4] move static log stuff to source --- CMakeLists.txt | 2 +- loader/include/Geode/loader/Log.hpp | 14 ++++-------- loader/src/loader/Log.cpp | 35 ++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92540ae4..34c34957 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ CPMAddPackage("gh:gulrak/filesystem#3e5b930") if (PROJECT_IS_TOP_LEVEL AND NOT GEODE_BUILDING_DOCS) set(TULIP_LINK_SOURCE ON) endif() -CPMAddPackage("gh:geode-sdk/TulipHook#a2c16d0") +CPMAddPackage("gh:geode-sdk/TulipHook#a00e2c6") target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp) diff --git a/loader/include/Geode/loader/Log.hpp b/loader/include/Geode/loader/Log.hpp index bea6cd1b..8681efaf 100644 --- a/loader/include/Geode/loader/Log.hpp +++ b/loader/include/Geode/loader/Log.hpp @@ -108,25 +108,19 @@ namespace geode { class GEODE_DLL Logger { private: - static inline std::vector s_logs; - static inline std::ofstream s_logStream; + static std::vector& logs(); + static std::ofstream& logStream(); Logger() = delete; ~Logger() = delete; // logs - static void _push(Log&& log); - public: static void setup(); - static inline void push(Log&& log) { - Logger::_push(std::move(log)); - } + static void push(Log&& log); - static inline void pop(Log* log) { - geode::utils::ranges::remove(Logger::s_logs, *log); - } + static void pop(Log* log); static std::vector list(); static void clear(); diff --git a/loader/src/loader/Log.cpp b/loader/src/loader/Log.cpp index c9204b71..61f4f3cb 100644 --- a/loader/src/loader/Log.cpp +++ b/loader/src/loader/Log.cpp @@ -183,30 +183,43 @@ void Log::addFormat(std::string_view formatStr, std::span compo // Logger -void Logger::setup() { - s_logStream = std::ofstream(dirs::getGeodeLogDir() / log::generateLogName()); +std::vector& Logger::logs() { + static std::vector logs; + return logs; +} +std::ofstream& Logger::logStream() { + static std::ofstream logStream; + return logStream; } -void Logger::_push(Log&& log) { +void Logger::setup() { + logStream() = std::ofstream(dirs::getGeodeLogDir() / log::generateLogName()); +} + +void Logger::push(Log&& log) { std::string logStr = log.toString(true); LoaderImpl::get()->logConsoleMessage(logStr); - s_logStream << logStr << std::endl; + logStream() << logStr << std::endl; - s_logs.emplace_back(std::forward(log)); + logs().emplace_back(std::forward(log)); +} + +void Logger::pop(Log* log) { + geode::utils::ranges::remove(Logger::logs(), *log); } std::vector Logger::list() { - std::vector logs; - logs.reserve(s_logs.size()); - for (auto& log : s_logs) { - logs.push_back(&log); + std::vector logs_; + logs_.reserve(logs().size()); + for (auto& log : logs()) { + logs_.push_back(&log); } - return logs; + return logs_; } void Logger::clear() { - s_logs.clear(); + logs().clear(); } // Misc From 771e514bc9a3d8977722c559ee2df3f508a2a6b7 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 12 Feb 2023 15:11:57 +0300 Subject: [PATCH 2/4] update tuliphook --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9095f45a..deeca14c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ CPMAddPackage("gh:gulrak/filesystem#3e5b930") if (PROJECT_IS_TOP_LEVEL AND NOT GEODE_BUILDING_DOCS) set(TULIP_LINK_SOURCE ON) endif() -CPMAddPackage("gh:geode-sdk/TulipHook#a00e2c6") +CPMAddPackage("gh:geode-sdk/TulipHook#055765a") target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp) From f1d0ac309fea08a6823d6027ec9b0f1ba2537246 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 12 Feb 2023 15:17:34 +0300 Subject: [PATCH 3/4] update tuliphook --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index deeca14c..967bb81d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ CPMAddPackage("gh:gulrak/filesystem#3e5b930") if (PROJECT_IS_TOP_LEVEL AND NOT GEODE_BUILDING_DOCS) set(TULIP_LINK_SOURCE ON) endif() -CPMAddPackage("gh:geode-sdk/TulipHook#055765a") +CPMAddPackage("gh:geode-sdk/TulipHook#122f060") target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp) From 461a75ca299ae58e452a9044d62115a2b39632b5 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 12 Feb 2023 15:47:27 +0300 Subject: [PATCH 4/4] revert tuliphook --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 967bb81d..133fa304 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ CPMAddPackage("gh:gulrak/filesystem#3e5b930") if (PROJECT_IS_TOP_LEVEL AND NOT GEODE_BUILDING_DOCS) set(TULIP_LINK_SOURCE ON) endif() -CPMAddPackage("gh:geode-sdk/TulipHook#122f060") +CPMAddPackage("gh:geode-sdk/TulipHook#a2c16d0") target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp)