Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Logger.cpp
Go to the documentation of this file.
1#include <Logger/Logger.h>
2
3#include <fstream>
4
5#include <Tools.h>
6#include <json.hpp>
7
9{
10 static std::string log_name("-1");
11 if (log_name == "-1")
12 {
13 const std::string config_path = ArkApi::Tools::GetCurrentDir() + "/config.json";
14 std::ifstream file{config_path};
15 if (!file.is_open())
16 {
17 log_name = "";
18 return "";
19 }
20
21 nlohmann::json config;
22 file >> config;
23 file.close();
24
25 log_name = config["settings"].value("StaticLogPath", "");
26 }
27
28 return log_name;
29}
30
31std::vector<spdlog::sink_ptr>& GetLogSinks()
32{
33 static std::vector<spdlog::sink_ptr> sinks{
34 std::make_shared<spdlog::sinks::wincolor_stdout_sink_mt>(),
35 std::make_shared<spdlog::sinks::rotating_file_sink_mt>(
36 !GetLogName().empty()
37 ? GetLogName()
38 : spdlog::sinks::default_daily_file_name_calculator::
39 calc_filename(
40 API::Tools::GetCurrentDir() + "/logs/ArkApi_" + std::to_string(GetCurrentProcessId()) + ".log"),
41 1024 * 1024, 5)
42 };
43
44 return sinks;
45}
std::string GetLogName()
Definition Logger.cpp:8
ARK_API std::vector< spdlog::sink_ptr > &APIENTRY GetLogSinks()
Definition Logger.cpp:31
Definition json.hpp:4518