45 #ifndef __BASE_LOGGING_HH__ 46 #define __BASE_LOGGING_HH__ 100 if (str.length() && str.back() !=
'\n' && str.back() !=
'\r')
107 template<
typename ...Args>
void 110 std::stringstream
ss;
112 print(loc, ss.str());
115 template<
typename ...Args>
void 118 print(loc, format.c_str(), args...);
129 virtual void log(
const Loc &loc, std::string
s) = 0;
136 #define base_message(logger, ...) \ 137 logger.print(::Logger::Loc(__FILE__, __LINE__), __VA_ARGS__) 147 #define base_message_once(...) do { \ 148 static bool once = false; \ 150 base_message(__VA_ARGS__); \ 155 #define exit_message(logger, ...) \ 157 base_message(logger, __VA_ARGS__); \ 158 logger.exit_helper(); \ 167 #define panic(...) exit_message(::Logger::getPanic(), __VA_ARGS__) 175 #define fatal(...) exit_message(::Logger::getFatal(), __VA_ARGS__) 185 #define panic_if(cond, ...) \ 188 panic("panic condition " # cond " occurred: %s", \ 189 csprintf(__VA_ARGS__)); \ 203 #define fatal_if(cond, ...) \ 206 fatal("fatal condition " # cond " occurred: %s", \ 207 csprintf(__VA_ARGS__)); \ 212 #define warn(...) base_message(::Logger::getWarn(), __VA_ARGS__) 213 #define inform(...) base_message(::Logger::getInfo(), __VA_ARGS__) 214 #define hack(...) base_message(::Logger::getHack(), __VA_ARGS__) 216 #define warn_once(...) base_message_once(::Logger::getWarn(), __VA_ARGS__) 217 #define inform_once(...) base_message_once(::Logger::getInfo(), __VA_ARGS__) 218 #define hack_once(...) base_message_once(::Logger::getHack(), __VA_ARGS__) 228 #define warn_if(cond, ...) \ 234 #define warn_if_once(cond, ...) \ 237 warn_once(__VA_ARGS__); \ 250 #define chatty_assert(cond, ...) 252 #define chatty_assert(cond, ...) \ 255 panic("assert(" # cond ") failed: %s", csprintf(__VA_ARGS__)); \ 258 #endif // __BASE_LOGGING_HH__
void ccprintf(cp::Print &print)
static Logger & getPanic()
static void setLevel(LogLevel ll)
Loc(const char *file, int line)
void exit_helper() M5_ATTR_NORETURN
Logger(const char *prefix)
static Logger & getInfo()
void print(const Loc &loc, const std::string &str)
static Logger & getWarn()
static Logger & getHack()
static Logger & getFatal()
Bitfield< 31, 29 > format
void print(const Loc &loc, const std::string &format, const Args &...args)
void print(const Loc &loc, const char *format, const Args &...args)
virtual void log(const Loc &loc, std::string s)=0