-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample_logprintf.cc
46 lines (39 loc) · 1.23 KB
/
example_logprintf.cc
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
// Copyright (c) 2022 Cory Fields
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
// Warn about any use of LogPrintf that does not end with a newline.
#include <string>
enum LogFlags {
NONE
};
enum Level {
None
};
template <typename... Args>
static inline void LogPrintf_(const std::string& logging_function, const std::string& source_file, const int source_line, const LogFlags flag, const Level level, const char* fmt, const Args&... args)
{
}
#define LogPrintLevel_(category, level, ...) LogPrintf_(__func__, __FILE__, __LINE__, category, level, __VA_ARGS__)
#define LogPrintf(...) LogPrintLevel_(LogFlags::NONE, Level::None, __VA_ARGS__)
// Use a macro instead of a function for conditional logging to prevent
// evaluating arguments when logging for the category is not enabled.
#define LogPrint(category, ...) \
do { \
LogPrintf(__VA_ARGS__); \
} while (0)
void good_func()
{
LogPrintf("hello world!\n");
}
void good_func2()
{
LogPrintf("hello world!...");
}
void bad_func()
{
LogPrintf("hello world!");
}
void bad_func2()
{
LogPrintf("hello world!..");
}