CIRCT  20.0.0git
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 { Debug , Info , Warning , Error }
 

Public Member Functions

 Logger (bool debugEnabled)
 
virtual ~Logger ()=default
 
bool getDebugEnabled ()
 
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. More...
 
virtual void error (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr)
 Report an error. More...
 
virtual void warning (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr)
 Report a warning. More...
 
virtual void info (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr)
 Report an informational message. More...
 
void debug (const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr)
 Report a debug message. More...
 
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. More...
 

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. More...
 
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. More...
 

Protected Attributes

bool debugEnabled = false
 Enable or disable debug messages. More...
 

Detailed Description

Definition at line 35 of file Logging.h.

Member Enumeration Documentation

◆ Level

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

Definition at line 37 of file Logging.h.

Constructor & Destructor Documentation

◆ Logger()

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

Definition at line 44 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 79 of file Logging.h.

References debugEnabled, and debugImpl().

Referenced by esi-cosim.Verilator::compile_commands(), 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 90 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 100 of file Logging.h.

References Debug, and log().

Referenced by 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 106 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 60 of file Logging.h.

References Error, and log().

Referenced by esi::loadBackend().

◆ getDebugEnabled()

bool esi::Logger::getDebugEnabled ( )
inline

Definition at line 46 of file Logging.h.

References debugEnabled.

◆ 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 71 of file Logging.h.

References Info, and log().

Referenced by 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::NullLogger, and esi::TSLogger.

Referenced by debugImpl(), error(), info(), and warning().

◆ 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 66 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 120 of file Logging.h.

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


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