The Sparta Modeling Framework
Loading...
Searching...
No Matches
LogUtils.hpp
1
// <LogUtils.hpp> -*- C++ -*-
2
3
#pragma once
4
5
#include <iomanip>
6
43
#ifndef SPARTA_LOG_CODE_BLOCK
44
#ifdef SPARTA_DISABLE_MACRO_LOGGING
45
#define SPARTA_LOG_CODE_BLOCK(logger, code)
46
#else
47
#define SPARTA_LOG_CODE_BLOCK(logger, code) \
48
if (SPARTA_EXPECT_FALSE(logger)) { \
49
code \
50
}
51
#endif
52
#endif
53
54
#ifndef DLOG_CODE_BLOCK
55
#define DLOG_CODE_BLOCK(code) SPARTA_LOG_CODE_BLOCK(debug_logger_, code)
56
#endif
57
58
#ifndef ILOG_CODE_BLOCK
59
#define ILOG_CODE_BLOCK(code) SPARTA_LOG_CODE_BLOCK( info_logger_, code)
60
#endif
61
62
#ifndef WLOG_CODE_BLOCK
63
#define WLOG_CODE_BLOCK(code) SPARTA_LOG_CODE_BLOCK( warn_logger_, code)
64
#endif
65
66
#ifndef SPARTA_LOG_OUTPUT
67
#define SPARTA_LOG_OUTPUT(logger, msg) logger << __func__ << ": " << msg;
68
#endif
69
70
#ifndef DLOG_OUTPUT
71
#define DLOG_OUTPUT(msg) SPARTA_LOG_OUTPUT(debug_logger_, msg)
72
#endif
73
74
#ifndef ILOG_OUTPUT
75
#define ILOG_OUTPUT(msg) SPARTA_LOG_OUTPUT( info_logger_, msg)
76
#endif
77
78
#ifndef WLOG_OUTPUT
79
#define WLOG_OUTPUT(msg) SPARTA_LOG_OUTPUT( warn_logger_, msg)
80
#endif
81
85
#ifndef SPARTA_LOG
86
#define SPARTA_LOG(logger, msg) SPARTA_LOG_CODE_BLOCK(logger, SPARTA_LOG_OUTPUT(logger, msg))
87
#endif
88
89
#ifndef DLOG
90
#define DLOG(msg) SPARTA_LOG(debug_logger_, msg)
91
#endif
92
93
#ifndef ILOG
94
#define ILOG(msg) SPARTA_LOG( info_logger_, msg)
95
#endif
96
97
#ifndef WLOG
98
#define WLOG(msg) SPARTA_LOG( warn_logger_, msg)
99
#endif
100
101
#ifndef SPARTA_LOG_IF
102
#define SPARTA_LOG_IF(logger, condition, msg) \
103
SPARTA_LOG_CODE_BLOCK(logger, \
104
if (condition) { \
105
SPARTA_LOG_OUTPUT(logger, msg) \
106
} \
107
)
108
#endif
109
110
#ifndef DLOG_IF
111
#define DLOG_IF(condition, msg) SPARTA_LOG_IF(debug_logger_, condition, msg)
112
#endif
113
114
#ifndef ILOG_IF
115
#define ILOG_IF(condition, msg) SPARTA_LOG_IF( info_logger_, condition, msg)
116
#endif
117
118
#ifndef WLOG_IF
119
#define WLOG_IF(condition, msg) SPARTA_LOG_IF( warn_logger_, condition, msg)
120
#endif
121
148
#ifndef HEX
149
#define HEX(val, width) \
150
"0x" << std::setw(width) << std::setfill('0') << std::hex \
151
<< std::right << val << std::setfill(' ') << std::dec
152
#endif
153
157
#ifndef HEX16
158
#define HEX16(val) HEX(val, 16)
159
#endif
160
164
#ifndef HEX8
165
#define HEX8(val) HEX(val, 8)
166
#endif
167
sparta
utils
LogUtils.hpp
Generated on Mon Dec 2 2024 20:57:05 for The Sparta Modeling Framework by
1.9.8