-
Notifications
You must be signed in to change notification settings - Fork 2
/
default_logger.h
119 lines (94 loc) · 2.49 KB
/
default_logger.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef DEFAULT_LOGGER_H
#define DEFAULT_LOGGER_H
#include "vsag/logger.h"
#include "vsag/options.h"
#include "fmt/format.h"
namespace vsag {
namespace logger {
enum class level {
trace = Logger::Level::kTRACE,
debug = Logger::Level::kDEBUG,
info = Logger::Level::kINFO,
warn = Logger::Level::kWARN,
err = Logger::Level::kERR,
critical = Logger::Level::kCRITICAL,
off = Logger::Level::kOFF
};
class ObDefaultLogger : public Logger {
public:
void
SetLevel(Logger::Level log_level) override;
void
Trace(const std::string& msg) override;
void
Debug(const std::string& msg) override;
void
Info(const std::string& msg) override;
void
Warn(const std::string& msg) override;
void
Error(const std::string& msg) override;
void
Critical(const std::string& msg) override;
};
inline void
set_level(level log_level) {
Options::Instance().logger()->SetLevel((Logger::Level)log_level);
}
inline void
trace(const std::string& msg) {
Options::Instance().logger()->Trace(msg);
}
inline void
debug(const std::string& msg) {
Options::Instance().logger()->Debug(msg);
}
inline void
info(const std::string& msg) {
Options::Instance().logger()->Info(msg);
}
inline void
warn(const std::string& msg) {
Options::Instance().logger()->Warn(msg);
}
inline void
error(const std::string& msg) {
Options::Instance().logger()->Error(msg);
}
inline void
critical(const std::string& msg) {
Options::Instance().logger()->Critical(msg);
}
template <typename... Args>
inline void
trace(fmt::format_string<Args...> fmt, Args&&... args) {
trace(fmt::format(fmt, std::forward<Args>(args)...));
}
template <typename... Args>
inline void
debug(fmt::format_string<Args...> fmt, Args&&... args) {
debug(fmt::format(fmt, std::forward<Args>(args)...));
}
template <typename... Args>
inline void
info(fmt::format_string<Args...> fmt, Args&&... args) {
info(fmt::format(fmt, std::forward<Args>(args)...));
}
template <typename... Args>
inline void
warn(fmt::format_string<Args...> fmt, Args&&... args) {
warn(fmt::format(fmt, std::forward<Args>(args)...));
}
template <typename... Args>
inline void
error(fmt::format_string<Args...> fmt, Args&&... args) {
error(fmt::format(fmt, std::forward<Args>(args)...));
}
template <typename... Args>
inline void
critical(fmt::format_string<Args...> fmt, Args&&... args) {
critical(fmt::format(fmt, std::forward<Args>(args)...));
}
} // namespace logger
} // namespace vsag
#endif //DEFAULT_LOGGER_H