-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_log.h
66 lines (51 loc) · 1.24 KB
/
util_log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Created by Shujian Qian on 2023-08-13.
//
#ifndef UTIL_LOG_H
#define UTIL_LOG_H
#include <memory>
#include <string_view>
#include "spdlog/spdlog.h"
namespace epic {
class Logger
{
public:
Logger(Logger &) = delete;
void operator=(const Logger &) = delete;
static Logger &GetInstance();
template<typename... Args>
void Trace(std::string_view fmt, Args... args)
{
logger->trace(fmt, args...);
}
template<typename... Args>
void Debug(std::string_view fmt, Args... args)
{
logger->debug(fmt, args...);
}
template<typename... Args>
void Info(std::string_view fmt, Args... args)
{
logger->info(fmt, std::forward<Args>(args)...);
}
template<typename... Args>
void Warn(std::string_view fmt, Args... args)
{
logger->warn(fmt, args...);
}
template<typename... Args>
void Error(std::string_view fmt, Args... args)
{
logger->error(fmt, args...);
}
void flush() {
logger->flush();
}
std::shared_ptr<spdlog::logger> logger = nullptr;
private:
static std::unique_ptr<Logger> instance;
Logger();
friend std::unique_ptr<Logger> std::make_unique<Logger>();
};
} // namespace epic
#endif // UTIL_LOG_H