gem5  v21.1.0.2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gem5::Logger Class Reference

#include <logging.hh>

Classes

struct  Loc
 

Public Types

enum  LogLevel {
  PANIC, FATAL, WARN, INFO,
  HACK, NUM_LOG_LEVELS
}
 

Public Member Functions

 Logger (const char *prefix)
 
virtual ~Logger ()
 
template<typename ... Args>
void print (const Loc &loc, const char *format, const Args &...args)
 
template<typename ... Args>
void print (const Loc &loc, const std::string &format, const Args &...args)
 
void exit_helper ()
 This helper is necessary since noreturn isn't inherited by virtual functions, and gcc will get mad if a function calls panic and then doesn't return. More...
 

Static Public Member Functions

static Logger & getPanic ()
 Get a Logger for the specified type of message. More...
 
static Logger & getFatal ()
 
static Logger & getWarn ()
 
static Logger & getInfo ()
 
static Logger & getHack ()
 
static void setLevel (LogLevel ll)
 

Protected Member Functions

virtual void log (const Loc &loc, std::string s)
 Generates the log message. More...
 
virtual void exit ()
 

Protected Attributes

bool enabled
 
const char * prefix
 

Detailed Description

Definition at line 54 of file logging.hh.

Member Enumeration Documentation

◆ LogLevel

Enumerator
PANIC 
FATAL 
WARN 
INFO 
HACK 
NUM_LOG_LEVELS 

Definition at line 67 of file logging.hh.

Constructor & Destructor Documentation

◆ Logger()

gem5::Logger::Logger ( const char *  prefix)
inline

Definition at line 90 of file logging.hh.

References prefix.

◆ ~Logger()

virtual gem5::Logger::~Logger ( )
inlinevirtual

Definition at line 95 of file logging.hh.

Member Function Documentation

◆ exit()

virtual void gem5::Logger::exit ( )
inlineprotectedvirtual

Definition at line 136 of file logging.hh.

Referenced by exit_helper().

◆ exit_helper()

void gem5::Logger::exit_helper ( )
inline

This helper is necessary since noreturn isn't inherited by virtual functions, and gcc will get mad if a function calls panic and then doesn't return.

Definition at line 124 of file logging.hh.

References exit().

◆ getFatal()

Logger & gem5::Logger::getFatal ( )
static

Definition at line 92 of file logging_mock.cc.

Referenced by setLevel(), TEST(), and TEST_F().

◆ getHack()

Logger & gem5::Logger::getHack ( )
static

Definition at line 110 of file logging_mock.cc.

Referenced by setLevel(), TEST(), and TEST_F().

◆ getInfo()

Logger & gem5::Logger::getInfo ( )
static

Definition at line 104 of file logging_mock.cc.

Referenced by setLevel(), TEST(), and TEST_F().

◆ getPanic()

Logger & gem5::Logger::getPanic ( )
static

Get a Logger for the specified type of message.

Definition at line 86 of file logging_mock.cc.

Referenced by setLevel(), TEST(), and TEST_F().

◆ getWarn()

Logger & gem5::Logger::getWarn ( )
static

Definition at line 98 of file logging_mock.cc.

Referenced by setLevel(), TEST(), and TEST_F().

◆ log()

virtual void gem5::Logger::log ( const Loc &  loc,
std::string  s 
)
inlineprotectedvirtual

Generates the log message.

By default it is sent to cerr.

Definition at line 131 of file logging.hh.

References gem5::Logger::Loc::file, gem5::Logger::Loc::line, and gem5::ArmISA::s.

Referenced by print().

◆ print() [1/2]

template<typename ... Args>
void gem5::Logger::print ( const Loc &  loc,
const char *  format,
const Args &...  args 
)
inline

Definition at line 98 of file logging.hh.

References gem5::ccprintf(), enabled, gem5::ArmISA::format, log(), prefix, and ss.

Referenced by print(), and TEST_F().

◆ print() [2/2]

template<typename ... Args>
void gem5::Logger::print ( const Loc &  loc,
const std::string &  format,
const Args &...  args 
)
inline

Definition at line 114 of file logging.hh.

References gem5::ArmISA::format, and print().

◆ setLevel()

static void gem5::Logger::setLevel ( LogLevel  ll)
inlinestatic

Definition at line 74 of file logging.hh.

References enabled, FATAL, getFatal(), getHack(), getInfo(), getPanic(), getWarn(), HACK, INFO, PANIC, and WARN.

Referenced by gem5::pybind_init_core(), and TEST_F().

Member Data Documentation

◆ enabled

bool gem5::Logger::enabled
protected

Definition at line 127 of file logging.hh.

Referenced by print(), and setLevel().

◆ prefix

const char* gem5::Logger::prefix
protected

Definition at line 138 of file logging.hh.

Referenced by Logger(), and print().


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

Generated on Tue Sep 21 2021 12:27:45 for gem5 by doxygen 1.8.17