Ark Server API 3.54
Serverside plugin support for Ark Survival Evolved.
Loading...
Searching...
No Matches
Logger.h
Go to the documentation of this file.
1#pragma once
2
3#include "../API/Base.h"
5
6ARK_API std::vector<spdlog::sink_ptr>& APIENTRY GetLogSinks();
7
8class Log
9{
10public:
11 Log(const Log&) = delete;
12 Log(Log&&) = delete;
13 Log& operator=(const Log&) = delete;
14 Log& operator=(Log&&) = delete;
15
16 static Log& Get()
17 {
18 static Log instance;
19 return instance;
20 }
21
22 static std::shared_ptr<spdlog::logger>& GetLog()
23 {
24 return Get().logger_;
25 }
26
27 void Init(const std::string& plugin_name)
28 {
29 auto& sinks = GetLogSinks();
30
31 logger_ = std::make_shared<spdlog::logger>(plugin_name, begin(sinks), end(sinks));
32
33 logger_->set_pattern("%D %R [%n][%l] %v");
35 }
36
37private:
38 Log() = default;
39 ~Log() = default;
40
41 std::shared_ptr<spdlog::logger> logger_;
42};
#define ARK_API
Definition: Base.h:9
ARK_API std::vector< spdlog::sink_ptr > &APIENTRY GetLogSinks()
Definition: Logger.cpp:31
Definition: Logger.h:9
Log()=default
~Log()=default
std::shared_ptr< spdlog::logger > logger_
Definition: Logger.h:41
Log(Log &&)=delete
Log & operator=(Log &&)=delete
void Init(const std::string &plugin_name)
Definition: Logger.h:27
static std::shared_ptr< spdlog::logger > & GetLog()
Definition: Logger.h:22
Log & operator=(const Log &)=delete
Log(const Log &)=delete
static Log & Get()
Definition: Logger.h:16