Loading [MathJax]/extensions/tex2jax.js
CIRCT 21.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
esi::Logger Class Referenceabstract

#include <Logging.h>

Inheritance diagram for esi::Logger:
Inheritance graph
[legend]
Collaboration diagram for esi::Logger:
Collaboration graph
[legend]

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.
 

Detailed Description

Definition at line 35 of file Logging.h.

Member Enumeration Documentation

◆ Level

enum class esi::Logger::Level
strong
Enumerator
Trace 
Debug 
Info 
Warning 
Error 

Definition at line 37 of file Logging.h.

Constructor & Destructor Documentation

◆ Logger()

esi::Logger::Logger ( bool  debugEnabled,
bool  traceEnabled 
)
inline

Definition at line 46 of file Logging.h.

◆ ~Logger()

virtual esi::Logger::~Logger ( )
virtualdefault

Member Function Documentation

◆ debug() [1/2]

void esi::Logger::debug ( const std::string &  subsystem,
const std::string &  msg,
const std::map< std::string, std::any > *  details = nullptr 
)
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().

◆ debug() [2/2]

void esi::Logger::debug ( std::function< void(std::string &subsystem, std::string &msg, std::unique_ptr< std::map< std::string, std::any > > &details)>  debugFunc)
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().

◆ debugImpl() [1/2]

virtual void esi::Logger::debugImpl ( const std::string &  subsystem,
const std::string &  msg,
const std::map< std::string, std::any > *  details 
)
inlineprotectedvirtual

Overrideable version of debug. Only gets called if debug is enabled.

Definition at line 133 of file Logging.h.

References Debug, and log().

Referenced by debug(), debug(), and debugImpl().

◆ debugImpl() [2/2]

virtual void esi::Logger::debugImpl ( std::function< void(std::string &subsystem, std::string &msg, std::unique_ptr< std::map< std::string, std::any > > &details)>  debugFunc)
inlineprotectedvirtual

Overrideable version of debug. Only gets called if debug is enabled.

Definition at line 139 of file Logging.h.

References debugEnabled, and debugImpl().

◆ error()

virtual void esi::Logger::error ( const std::string &  subsystem,
const std::string &  msg,
const std::map< std::string, std::any > *  details = nullptr 
)
inlinevirtual

Report an error.

Definition at line 64 of file Logging.h.

References Error, and log().

Referenced by esi::loadBackend().

◆ getDebugEnabled()

bool esi::Logger::getDebugEnabled ( )
inline

Definition at line 49 of file Logging.h.

References debugEnabled.

◆ getTraceEnabled()

bool esi::Logger::getTraceEnabled ( )
inline

Definition at line 50 of file Logging.h.

References traceEnabled.

◆ info()

virtual void esi::Logger::info ( const std::string &  subsystem,
const std::string &  msg,
const std::map< std::string, std::any > *  details = nullptr 
)
inlinevirtual

Report an informational message.

Definition at line 75 of file Logging.h.

References Info, and log().

Referenced by bandwidthReadTest(), bandwidthWriteTest(), dmaReadTest(), dmaWriteTest(), and esi::loadBackend().

◆ log()

virtual void esi::Logger::log ( Level  level,
const std::string &  subsystem,
const std::string &  msg,
const std::map< std::string, std::any > *  details = nullptr 
)
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().

◆ trace() [1/2]

void esi::Logger::trace ( const std::string &  subsystem,
const std::string &  msg,
const std::map< std::string, std::any > *  details = nullptr 
)
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.

◆ trace() [2/2]

void esi::Logger::trace ( std::function< void(std::string &subsystem, std::string &msg, std::unique_ptr< std::map< std::string, std::any > > &details)>  traceFunc)
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.

◆ warning()

virtual void esi::Logger::warning ( const std::string &  subsystem,
const std::string &  msg,
const std::map< std::string, std::any > *  details = nullptr 
)
inlinevirtual

Report a warning.

Definition at line 70 of file Logging.h.

References log(), and Warning.

Member Data Documentation

◆ debugEnabled

bool esi::Logger::debugEnabled = false
protected

Enable or disable debug messages.

Definition at line 153 of file Logging.h.

Referenced by debug(), debug(), debugImpl(), and getDebugEnabled().

◆ traceEnabled

bool esi::Logger::traceEnabled
protected

Enable or disable trace messages.

Definition at line 156 of file Logging.h.

Referenced by getTraceEnabled(), trace(), and trace().


The documentation for this class was generated from the following file: