CIRCT 21.0.0git
|
#include <Logging.h>
Public Types | |
enum class | Level { Trace , Debug , Info , Warning , Error } |
Public Member Functions | |
Logger (bool debugEnabled, bool traceEnabled) | |
virtual | ~Logger ()=default |
bool | getDebugEnabled () |
bool | getTraceEnabled () |
virtual void | log (Level level, const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr)=0 |
Report a log message. | |
virtual void | error (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr) |
Report an error. | |
virtual void | warning (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr) |
Report a warning. | |
virtual void | info (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr) |
Report an informational message. | |
void | debug (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr) |
Report a debug message. | |
void | debug (std::function< void(std::string &subsystem, std::string &msg, std::unique_ptr< std::map< std::string, std::any > > &details)> debugFunc) |
Call the debug function callback only if debug is enabled then log a debug message. | |
void | trace (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr) |
Log a trace message. | |
void | trace (std::function< void(std::string &subsystem, std::string &msg, std::unique_ptr< std::map< std::string, std::any > > &details)> traceFunc) |
Log a trace message using a callback. | |
Protected Member Functions | |
virtual void | debugImpl (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details) |
Overrideable version of debug. Only gets called if debug is enabled. | |
virtual void | debugImpl (std::function< void(std::string &subsystem, std::string &msg, std::unique_ptr< std::map< std::string, std::any > > &details)> debugFunc) |
Overrideable version of debug. Only gets called if debug is enabled. | |
Protected Attributes | |
bool | debugEnabled = false |
Enable or disable debug messages. | |
bool | traceEnabled |
Enable or disable trace messages. | |
|
strong |
|
inline |
|
virtualdefault |
|
inline |
Report a debug message.
This is not virtual so that it can be inlined to minimize performance impact that debug messages have, allowing debug messages in Release builds.
Definition at line 83 of file Logging.h.
References debugEnabled, and debugImpl().
Referenced by bandwidthReadTest(), bandwidthWriteTest(), esi-cosim.Verilator::compile_commands(), dmaReadTest(), esi::loadBackend(), registerCallbacks(), and esi-cosim.Simulator::run().
|
inline |
Call the debug function callback only if debug is enabled then log a debug message.
Allows users to run heavy weight debug message generation code only when debug is enabled, which in turns allows users to provide fully-featured debug messages in Release builds with minimal performance impact. Not virtual so that it can be inlined.
Definition at line 94 of file Logging.h.
References debugEnabled, and debugImpl().
Referenced by esi-cosim.Verilator::compile_commands(), and esi-cosim.Simulator::run().
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
Overrideable version of debug. Only gets called if debug is enabled.
Definition at line 139 of file Logging.h.
References debugEnabled, and debugImpl().
|
inlinevirtual |
|
inline |
Definition at line 49 of file Logging.h.
References debugEnabled.
|
inline |
Definition at line 50 of file Logging.h.
References traceEnabled.
|
inlinevirtual |
Report an informational message.
Definition at line 75 of file Logging.h.
Referenced by bandwidthReadTest(), bandwidthWriteTest(), dmaReadTest(), dmaWriteTest(), and esi::loadBackend().
|
pure virtual |
Report a log message.
Arguments: level: The log level as defined by the 'Level' enum above. subsystem: The subsystem that generated the log message. msg: The log message. details: Optional additional structured details to include in the log message. If there are no details, this should be nullptr.
Implemented in esi::TSLogger, and esi::NullLogger.
Referenced by debugImpl(), error(), info(), trace(), trace(), and warning().
|
inline |
Log a trace message.
If tracing is not enabled, this is a no-op. Since it is inlined, the compiler will hopefully optimize it away creating a zero-overhead call. This means that clients are free to go crazy with trace messages.
Definition at line 106 of file Logging.h.
References log(), Trace, and traceEnabled.
|
inline |
Log a trace message using a callback.
Same as above, users can go hog-wild calling this.
Definition at line 116 of file Logging.h.
References log(), Trace, and traceEnabled.
|
inlinevirtual |
|
protected |
Enable or disable debug messages.
Definition at line 153 of file Logging.h.
Referenced by debug(), debug(), debugImpl(), and getDebugEnabled().
|
protected |
Enable or disable trace messages.
Definition at line 156 of file Logging.h.
Referenced by getTraceEnabled(), trace(), and trace().