Browse Source

refactor(CAPI): change logger to unique ptr

tags/0.1.0
DragonAura 3 years ago
parent
commit
50afe72cde
4 changed files with 6 additions and 6 deletions
  1. +2
    -2
      CAPI/API/include/API.h
  2. +1
    -1
      CAPI/API/include/logic.h
  3. +2
    -2
      CAPI/API/src/DebugAPI.cpp
  4. +1
    -1
      CAPI/API/src/logic.cpp

+ 2
- 2
CAPI/API/include/API.h View File

@@ -315,7 +315,7 @@ public:

private:
std::chrono::system_clock::time_point StartPoint;
std::shared_ptr<spdlog::logger> logger;
std::unique_ptr<spdlog::logger> logger;
ILogic& logic;
};

@@ -363,7 +363,7 @@ public:

private:
std::chrono::system_clock::time_point StartPoint;
std::shared_ptr<spdlog::logger> logger;
std::unique_ptr<spdlog::logger> logger;
ILogic& logic;
};



+ 1
- 1
CAPI/API/include/logic.h View File

@@ -35,7 +35,7 @@ class Logic : public ILogic
{
private:
// 日志组件
std::shared_ptr<spdlog::logger> logger;
std::unique_ptr<spdlog::logger> logger;

// 通信组件
std::unique_ptr<Communication> pComm;


+ 2
- 2
CAPI/API/src/DebugAPI.cpp View File

@@ -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<spdlog::logger>("apiLogger", spdlog::sinks_init_list{fileLogger, printLogger});
logger = std::make_unique<spdlog::logger>("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<spdlog::logger>("apiLogger", spdlog::sinks_init_list{fileLogger, printLogger});
logger = std::make_unique<spdlog::logger>("apiLogger", spdlog::sinks_init_list{fileLogger, printLogger});
}

void HumanDebugAPI::StartTimer()


+ 1
- 1
CAPI/API/src/logic.cpp View File

@@ -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<spdlog::logger>("logicLogger", spdlog::sinks_init_list{fileLogger, printLogger});
logger = std::make_unique<spdlog::logger>("logicLogger", spdlog::sinks_init_list{fileLogger, printLogger});

// 建立与服务器之间通信的组件
pComm = std::make_unique<Communication>(IP, port);


Loading…
Cancel
Save