-
Notifications
You must be signed in to change notification settings - Fork 0
/
glog.h
80 lines (67 loc) · 1.67 KB
/
glog.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
#ifndef GLOG_H
#define GLOG_H
#include <string>
#include <iostream>
class GLog
{
public:
enum GLogType
{
kInfo,
kWarning,
kError
};
template<typename... Targs>
static void Log(GLogType logT, Targs... logs)
{
std::string tag;
switch (logT)
{
case GLogType::kInfo:
tag = "INFO : ";
break;
case GLogType::kWarning:
tag = "WARN : ";
break;
case GLogType::kError:
tag = "ERRO : ";
break;
}
std::cout << tag;
LogTValue(logs...);
std::cout << std::endl;
}
template<typename... Targs> static void LogInfo(Targs... log)
{
Log(GLogType::kInfo, log...);
}
template<typename... Targs> static void LogWarning(Targs... log)
{
Log(GLogType::kWarning, log...);
}
template<typename... Targs> static void LogError(Targs... log)
{
Log(GLogType::kError, log...);
}
private:
template<typename T>
static void LogTValue(T log)
{
std::cout << log;
}
template<typename T, typename... Targs>
static void LogTValue(T log, Targs ... logs)
{
LogTValue(log);
LogTValue(logs ...);
}
};
/*
#define CHECK_FAIL_LOG_INFO(CONDITION, LOG_STR, ...) \
(CONDITION) ? true : (GLog::LogInfo(LOG_STR, ##__VA_ARGS__), false);
#define CHECK_FAIL_LOG_WARN(CONDITION, LOG_STR, ...) \
(CONDITION) ? true : (GLog::LogWarning(LOG_STR, ##__VA_ARGS__), false);
#define CHECK_FAIL_LOG_ERROR(CONDITION, LOG_STR, ...) \
(CONDITION) ? true : (GLog::LogError(LOG_STR, ##__VA_ARGS__), false);
*/
#endif // GLOG_H