The Sparta Modeling Framework
|
Macros | |
#define | SPARTA_LOG_CODE_BLOCK(logger, code) |
#define | DLOG_CODE_BLOCK(code) SPARTA_LOG_CODE_BLOCK(debug_logger_, code) |
#define | ILOG_CODE_BLOCK(code) SPARTA_LOG_CODE_BLOCK( info_logger_, code) |
#define | WLOG_CODE_BLOCK(code) SPARTA_LOG_CODE_BLOCK( warn_logger_, code) |
#define | SPARTA_LOG_OUTPUT(logger, msg) logger << __func__ << ": " << msg; |
#define | DLOG_OUTPUT(msg) SPARTA_LOG_OUTPUT(debug_logger_, msg) |
#define | ILOG_OUTPUT(msg) SPARTA_LOG_OUTPUT( info_logger_, msg) |
#define | WLOG_OUTPUT(msg) SPARTA_LOG_OUTPUT( warn_logger_, msg) |
#define | SPARTA_LOG(logger, msg) SPARTA_LOG_CODE_BLOCK(logger, SPARTA_LOG_OUTPUT(logger, msg)) |
#define | DLOG(msg) SPARTA_LOG(debug_logger_, msg) |
#define | ILOG(msg) SPARTA_LOG( info_logger_, msg) |
#define | WLOG(msg) SPARTA_LOG( warn_logger_, msg) |
#define | SPARTA_LOG_IF(logger, condition, msg) |
#define | DLOG_IF(condition, msg) SPARTA_LOG_IF(debug_logger_, condition, msg) |
#define | ILOG_IF(condition, msg) SPARTA_LOG_IF( info_logger_, condition, msg) |
#define | WLOG_IF(condition, msg) SPARTA_LOG_IF( warn_logger_, condition, msg) |
These macros are meant to be used within a method within a class that derives from sparta::Unit to simplify sending messages to the debug, info, and warn loggers defined in the sparta::Unit base class.
Example usage:
class Fetch : public sparta::Unit { void FetchSomeInsts() const { const int val = 5; DLOG("Got " << val << " instructions"); } }
Example debug logger output:
{0000000000 00000000 top.fetch debug} FetchSomeInsts: Got 5 instructions
#define DLOG | ( | msg | ) | SPARTA_LOG(debug_logger_, msg) |
Definition at line 90 of file LogUtils.hpp.
#define DLOG_CODE_BLOCK | ( | code | ) | SPARTA_LOG_CODE_BLOCK(debug_logger_, code) |
Definition at line 55 of file LogUtils.hpp.
#define DLOG_IF | ( | condition, | |
msg | |||
) | SPARTA_LOG_IF(debug_logger_, condition, msg) |
Definition at line 111 of file LogUtils.hpp.
#define DLOG_OUTPUT | ( | msg | ) | SPARTA_LOG_OUTPUT(debug_logger_, msg) |
Definition at line 71 of file LogUtils.hpp.
#define ILOG | ( | msg | ) | SPARTA_LOG( info_logger_, msg) |
Definition at line 94 of file LogUtils.hpp.
#define ILOG_CODE_BLOCK | ( | code | ) | SPARTA_LOG_CODE_BLOCK( info_logger_, code) |
Definition at line 59 of file LogUtils.hpp.
#define ILOG_IF | ( | condition, | |
msg | |||
) | SPARTA_LOG_IF( info_logger_, condition, msg) |
Definition at line 115 of file LogUtils.hpp.
#define ILOG_OUTPUT | ( | msg | ) | SPARTA_LOG_OUTPUT( info_logger_, msg) |
Definition at line 75 of file LogUtils.hpp.
#define SPARTA_LOG | ( | logger, | |
msg | |||
) | SPARTA_LOG_CODE_BLOCK(logger, SPARTA_LOG_OUTPUT(logger, msg)) |
Macro to simplify sending messages to the Unit logger
msg | The message to send to the logger |
Definition at line 86 of file LogUtils.hpp.
#define SPARTA_LOG_CODE_BLOCK | ( | logger, | |
code | |||
) |
The main motivation for decomposition into *LOG_CODE_BLOCK and *LOG_OUTPUT is to support something like the following:
DLOG_CODE_BLOCK( std::ostringstream oss; // Complex sequence of various outputs to the ostringstream // ... DLOG_OUTPUT(oss.str()); )
The preprocessor can then still completely eliminate a complex logging message like this if SPARTA_DISABLE_MACRO_LOGGING is defined. It also allows a complex logging message to have consistent format with all other logging messages.
Definition at line 47 of file LogUtils.hpp.
#define SPARTA_LOG_IF | ( | logger, | |
condition, | |||
msg | |||
) |
Definition at line 102 of file LogUtils.hpp.
#define SPARTA_LOG_OUTPUT | ( | logger, | |
msg | |||
) | logger << __func__ << ": " << msg; |
Definition at line 67 of file LogUtils.hpp.
#define WLOG | ( | msg | ) | SPARTA_LOG( warn_logger_, msg) |
Definition at line 98 of file LogUtils.hpp.
#define WLOG_CODE_BLOCK | ( | code | ) | SPARTA_LOG_CODE_BLOCK( warn_logger_, code) |
Definition at line 63 of file LogUtils.hpp.
#define WLOG_IF | ( | condition, | |
msg | |||
) | SPARTA_LOG_IF( warn_logger_, condition, msg) |
Definition at line 119 of file LogUtils.hpp.
#define WLOG_OUTPUT | ( | msg | ) | SPARTA_LOG_OUTPUT( warn_logger_, msg) |
Definition at line 79 of file LogUtils.hpp.