From 50afe72cdeec772ccee67fefbb60d76c3fb69cf5 Mon Sep 17 00:00:00 2001 From: DragonAura Date: Mon, 16 Jan 2023 16:41:59 +0800 Subject: [PATCH] refactor(CAPI): :zap: change logger to unique ptr --- CAPI/API/include/API.h | 4 ++-- CAPI/API/include/logic.h | 2 +- CAPI/API/src/DebugAPI.cpp | 4 ++-- CAPI/API/src/logic.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CAPI/API/include/API.h b/CAPI/API/include/API.h index a123998..ecb8430 100644 --- a/CAPI/API/include/API.h +++ b/CAPI/API/include/API.h @@ -315,7 +315,7 @@ public: private: std::chrono::system_clock::time_point StartPoint; - std::shared_ptr logger; + std::unique_ptr logger; ILogic& logic; }; @@ -363,7 +363,7 @@ public: private: std::chrono::system_clock::time_point StartPoint; - std::shared_ptr logger; + std::unique_ptr logger; ILogic& logic; }; diff --git a/CAPI/API/include/logic.h b/CAPI/API/include/logic.h index a095a5c..dfc80dc 100644 --- a/CAPI/API/include/logic.h +++ b/CAPI/API/include/logic.h @@ -35,7 +35,7 @@ class Logic : public ILogic { private: // 日志组件 - std::shared_ptr logger; + std::unique_ptr logger; // 通信组件 std::unique_ptr pComm; diff --git a/CAPI/API/src/DebugAPI.cpp b/CAPI/API/src/DebugAPI.cpp index 26894ae..3bd066c 100644 --- a/CAPI/API/src/DebugAPI.cpp +++ b/CAPI/API/src/DebugAPI.cpp @@ -23,7 +23,7 @@ HumanDebugAPI::HumanDebugAPI(ILogic& logic, bool file, bool print, bool warnOnly printLogger->set_level(spdlog::level::off); if (warnOnly) printLogger->set_level(spdlog::level::warn); - logger = std::make_shared("apiLogger", spdlog::sinks_init_list{fileLogger, printLogger}); + logger = std::make_unique("apiLogger", spdlog::sinks_init_list{fileLogger, printLogger}); } ButcherDebugAPI::ButcherDebugAPI(ILogic& logic, bool file, bool print, bool warnOnly, int64_t playerID) : @@ -45,7 +45,7 @@ ButcherDebugAPI::ButcherDebugAPI(ILogic& logic, bool file, bool print, bool warn printLogger->set_level(spdlog::level::off); if (warnOnly) printLogger->set_level(spdlog::level::warn); - logger = std::make_shared("apiLogger", spdlog::sinks_init_list{fileLogger, printLogger}); + logger = std::make_unique("apiLogger", spdlog::sinks_init_list{fileLogger, printLogger}); } void HumanDebugAPI::StartTimer() diff --git a/CAPI/API/src/logic.cpp b/CAPI/API/src/logic.cpp index efcf5f6..073638f 100644 --- a/CAPI/API/src/logic.cpp +++ b/CAPI/API/src/logic.cpp @@ -449,7 +449,7 @@ void Logic::Main(CreateAIFunc createAI, std::string IP, std::string port, bool f printLogger->set_level(spdlog::level::off); if (warnOnly) printLogger->set_level(spdlog::level::warn); - logger = std::make_shared("logicLogger", spdlog::sinks_init_list{fileLogger, printLogger}); + logger = std::make_unique("logicLogger", spdlog::sinks_init_list{fileLogger, printLogger}); // 建立与服务器之间通信的组件 pComm = std::make_unique(IP, port);