librime: no_logging.h Source File

| librime 1.2 Rime Input Method Engine, the core library

no_logging.h
Go to the documentation of this file.
1#ifndef RIME_NO_LOGGING_H_
2#define RIME_NO_LOGGING_H_
3
4namespace rime {
5
6 class VoidLogger {
7 public:
8 VoidLogger() {}
9
10 // hack: an unnamed VoidLogger() cannot be used as an l-value
11 VoidLogger& stream() { return *this; }
12
13 template <class T>
14 VoidLogger& operator<<(const T& x) {
15 return *this;
16 }
17};
18
19// to avoid compiler warnings
20 class Voidify {
21 public:
22 Voidify() {}
23 void operator&(VoidLogger&) {}
24};
25
26} // namespace rime
27
28#define RIME_NO_LOG \
29 true ? (void)0 : rime::Voidify() & rime::VoidLogger().stream()
30
31#define LOG(severity) RIME_NO_LOG
32#define VLOG(verboselevel) RIME_NO_LOG
33#define LOG_IF(severity, condition) RIME_NO_LOG
34#define LOG_EVERY_N(severity, n) RIME_NO_LOG
35#define LOG_IF_EVERY_N(severity, condition, n) RIME_NO_LOG
36#define LOG_ASSERT(condition) RIME_NO_LOG
37
38#define RIME_NO_CHECK (void)0
39
40#define CHECK(condition) RIME_NO_CHECK
41#define CHECK_EQ(val1, val2) RIME_NO_CHECK
42#define CHECK_NE(val1, val2) RIME_NO_CHECK
43#define CHECK_LE(val1, val2) RIME_NO_CHECK
44#define CHECK_LT(val1, val2) RIME_NO_CHECK
45#define CHECK_GE(val1, val2) RIME_NO_CHECK
46#define CHECK_GT(val1, val2) RIME_NO_CHECK
47#define CHECK_NOTNULL(val) RIME_NO_CHECK
48#define CHECK_STREQ(str1, str2) RIME_NO_CHECK
49#define CHECK_STRCASEEQ(str1, str2) RIME_NO_CHECK
50#define CHECK_STRNE(str1, str2) RIME_NO_CHECK
51#define CHECK_STRCASENE(str1, str2) RIME_NO_CHECK
52
53#define DLOG(severity) LOG(severity)
54#define DVLOG(verboselevel) VLOG(verboselevel)
55#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
56#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n)
57#define DLOG_IF_EVERY_N(severity, condition, n) \
58 LOG_IF_EVERY_N(severity, condition, n)
59#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
60
61#define DCHECK(condition) CHECK(condition)
62#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
63#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
64#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
65#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
66#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
67#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
68#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val)
69#define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2)
70#define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2)
71#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
72#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
73
74#endif // RIME_NO_LOGGING_H_
rime
Definition algebra.cc:12
rime::VoidLogger
Definition no_logging.h:6
rime::VoidLogger::stream
VoidLogger & stream()
Definition no_logging.h:11
rime::VoidLogger::VoidLogger
VoidLogger()
Definition no_logging.h:8
rime::VoidLogger::operator<<
VoidLogger & operator<<(const T &x)
Definition no_logging.h:14
rime::Voidify::operator&
void operator&(VoidLogger &)
Definition no_logging.h:23
rime::Voidify::Voidify
Voidify()
Definition no_logging.h:22