This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
forked from Gaomengkai/Vrabche
-
Notifications
You must be signed in to change notification settings - Fork 0
/
R5Logger.h
66 lines (55 loc) · 2.88 KB
/
R5Logger.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
//
// Created by gaome on 2023/7/13.
//
#ifndef IRBACKENDR5_R5LOGGER_H
#define IRBACKENDR5_R5LOGGER_H
#ifndef SYSY_LOGGER
# define SYSY_LOGGER
# include <iostream>
namespace MiddleIR
{
enum LOG_LEVEL {
LOG_LEVEL_DEBUG,
LOG_LEVEL_WARNING,
LOG_LEVEL_ERROR,
};
extern LOG_LEVEL g_log_level;
std::ostream& sysyDebug(LOG_LEVEL level = LOG_LEVEL_DEBUG);
} // namespace MiddleIR
# define ANSI_COLOR_BLUE "\033[1;34m"
# define ANSI_COLOR_ORANGE "\033[1;33m"
# define ANSI_COLOR_YELLOW "\033[1;93m"
# define ANSI_COLOR_RED "\033[1;31m"
# define ANSI_COLOR_RESET "\033[0m"
# define LOGD(message) \
do { \
MiddleIR::sysyDebug(MiddleIR::LOG_LEVEL_DEBUG) \
<< ANSI_COLOR_BLUE << "[D] File: " << __FILE__ << ANSI_COLOR_RESET \
<< ANSI_COLOR_ORANGE << ":" << __LINE__ << ANSI_COLOR_RESET << ":\t" << message \
<< std::endl; \
} while (0)
# define LOGW(message) \
do { \
MiddleIR::sysyDebug(MiddleIR::LOG_LEVEL_WARNING) \
<< ANSI_COLOR_YELLOW << "[W] File: " << __FILE__ << ANSI_COLOR_RESET \
<< ANSI_COLOR_ORANGE << ":" << __LINE__ << ANSI_COLOR_RESET << ":\t" \
<< ANSI_COLOR_YELLOW << message << ANSI_COLOR_RESET << std::endl; \
} while (0)
# define LOGE(message) \
do { \
MiddleIR::sysyDebug(MiddleIR::LOG_LEVEL_ERROR) \
<< ANSI_COLOR_RED << "[E] File: " << __FILE__ << ANSI_COLOR_RESET \
<< ANSI_COLOR_ORANGE << ":" << __LINE__ << ANSI_COLOR_RESET << ":\t" \
<< ANSI_COLOR_RED << message << ANSI_COLOR_RESET << std::endl; \
} while (0)
# define RUNTIME_ERROR(message) \
do { \
LOGE(message); \
throw std::runtime_error(std::string(__FILE__) + ":" + std::to_string(__LINE__)); \
} while (0)
# define IR_ASSERT(EXP_, MSG_) \
do { \
if (!(EXP_)) { RUNTIME_ERROR(MSG_); } \
} while (0)
#endif
#endif // IRBACKENDR5_R5LOGGER_H