Cuberite
A lightweight, fast and extensible game server for Minecraft
LoggerSimple.h
Go to the documentation of this file.
1 
2 // Logging free functions defined in Logger.cpp
3 #pragma once
4 
5 enum class eLogLevel
6 {
7  Regular,
8  Info,
9  Warning,
10  Error,
11 };
12 
13 namespace Logger
14 {
15 
16 extern void LogFormat(
17  std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList
18 );
19 extern void LogPrintf(
20  std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList
21 );
22 extern void LogSimple(std::string_view a_Message, eLogLevel a_LogLevel);
23 
24 } // namespace Logger
25 
26 // python style format specified logging
27 
28 template <typename... Args>
29 void FLOG(std::string_view a_Format, const Args & ... args)
30 {
31  Logger::LogFormat(a_Format, eLogLevel::Regular, fmt::make_format_args(args...));
32 }
33 
34 template <typename... Args>
35 void FLOGINFO(std::string_view a_Format, const Args & ... args)
36 {
37  Logger::LogFormat(a_Format, eLogLevel::Info, fmt::make_format_args(args...));
38 }
39 
40 template <typename... Args>
41 void FLOGWARNING(std::string_view a_Format, const Args & ... args)
42 {
43  Logger::LogFormat(a_Format, eLogLevel::Warning, fmt::make_format_args(args...));
44 }
45 
46 template <typename... Args>
47 void FLOGERROR(std::string_view a_Format, const Args & ... args)
48 {
49  Logger::LogFormat(a_Format, eLogLevel::Error, fmt::make_format_args(args...));
50 }
51 
52 // printf style format specified logging (DEPRECATED)
53 
54 template <typename... Args>
55 void LOG(std::string_view a_Format, const Args & ... args)
56 {
57  Logger::LogPrintf(a_Format, eLogLevel::Regular, fmt::make_printf_args(args...));
58 }
59 
60 template <typename... Args>
61 void LOGINFO(std::string_view a_Format, const Args & ... args)
62 {
63  Logger::LogPrintf(a_Format, eLogLevel::Info, fmt::make_printf_args(args...));
64 }
65 
66 template <typename... Args>
67 void LOGWARNING(std::string_view a_Format, const Args & ... args)
68 {
69  Logger::LogPrintf(a_Format, eLogLevel::Warning, fmt::make_printf_args(args...));
70 }
71 
72 template <typename... Args>
73 void LOGERROR(std::string_view a_Format, const Args & ... args)
74 {
75  Logger::LogPrintf(a_Format, eLogLevel::Error, fmt::make_printf_args(args...));
76 }
77 
78 
79 // Macro variants
80 
81 // In debug builds, translate LOGD to LOG, otherwise leave it out altogether:
82 #if !defined(NDEBUG) || defined(TEST_GLOBALS)
83  #define LOGD LOG
84 #else
85  #define LOGD(...)
86 #endif // !NDEBUG
87 
88 #define LOGWARN LOGWARNING
89 
90 #if !defined(NDEBUG) || defined(TEST_GLOBALS)
91  #define FLOGD FLOG
92 #else
93  #define FLOGD(...)
94 #endif // !NDEBUG
95 
96 #define FLOGWARN FLOGWARNING
97 
98 // Conditionally log a warning
99 #define CONDWARNING(ShouldLog, ...) \
100  do { \
101  if (ShouldLog) \
102  { \
103  LOGWARNING(__VA_ARGS__); \
104  } \
105  } while (false)
Logger::LogSimple
void LogSimple(std::string_view a_Message, eLogLevel a_LogLevel)
Definition: Logger.cpp:169
Logger::LogFormat
void LogFormat(std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList)
Definition: Logger.cpp:151
LOGINFO
void LOGINFO(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:61
eLogLevel::Info
@ Info
eLogLevel::Warning
@ Warning
eLogLevel::Regular
@ Regular
LOGERROR
void LOGERROR(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:73
FLOGWARNING
void FLOGWARNING(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:41
LOGWARNING
void LOGWARNING(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:67
eLogLevel::Error
@ Error
FLOG
void FLOG(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:29
Logger::LogPrintf
void LogPrintf(std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList)
Definition: Logger.cpp:160
FLOGERROR
void FLOGERROR(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:47
eLogLevel
eLogLevel
Definition: LoggerSimple.h:5
LOG
void LOG(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:55
FLOGINFO
void FLOGINFO(std::string_view a_Format, const Args &... args)
Definition: LoggerSimple.h:35
Logger
Definition: LoggerSimple.h:13