45 #ifndef __BASE_MISC_HH__
46 #define __BASE_MISC_HH__
56 #if defined(__SUNPRO_CC)
57 #define __FUNCTION__ "how to fix me?"
94 template<
typename ...Args>
void
95 print(
const char *func,
const char *file,
int line,
96 const char *
format,
const Args &...args)
108 template<
typename ...Args>
void
109 print(
const char *func,
const char *file,
int line,
110 const std::string &
format,
const Args &...args)
112 print(func, file, line, format.c_str(), args...);
116 virtual void printEpilogue(
const char *func,
const char *file,
int line,
133 void printEpilogue(
const char *func,
const char *file,
int line,
134 const char *
format)
override;
137 #define exit_message(logger, code, ...) \
139 logger.print(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__); \
153 #define panic(...) exit_message(::Logger::get(::Logger::PANIC), -1, \
163 #define fatal(...) exit_message(::Logger::get(::Logger::FATAL), 1, \
174 #define panic_if(cond, ...) \
177 panic("panic condition " # cond " occurred: %s", \
178 csprintf(__VA_ARGS__)); \
192 #define fatal_if(cond, ...) \
195 fatal("fatal condition " # cond " occurred: %s", \
196 csprintf(__VA_ARGS__)); \
201 #define base_message(logger, ...) \
202 logger.print(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
210 #define base_message_once(...) do { \
211 static bool once = false; \
213 base_message(__VA_ARGS__); \
220 base_message(::Logger::get(::Logger::WARN), __VA_ARGS__)
221 #define inform(...) \
222 base_message(::Logger::get(::Logger::INFO), __VA_ARGS__)
224 base_message(::Logger::get(::Logger::HACK), __VA_ARGS__)
226 #define warn_once(...) \
227 base_message_once(::Logger::get(::Logger::WARN), __VA_ARGS__)
228 #define inform_once(...) \
229 base_message_once(::Logger::get(::Logger::INFO), __VA_ARGS__)
230 #define hack_once(...) \
231 base_message_once(::Logger::get(::Logger::HACK), __VA_ARGS__)
241 #define warn_if(cond, ...) \
257 #define chatty_assert(cond, ...)
259 #define chatty_assert(cond, ...) \
262 panic("assert(" # cond ") failed: %s", csprintf(__VA_ARGS__)); \
265 #endif // __BASE_MISC_HH__
void ccprintf(cp::Print &print)
void print(const char *func, const char *file, int line, const std::string &format, const Args &...args)
void printEpilogue(const char *func, const char *file, int line, const char *format) override
void print(const char *func, const char *file, int line, const char *format, const Args &...args)
virtual void printEpilogue(const char *func, const char *file, int line, const char *format)
Logger(std::ostream &stream, const char *prefix)
Bitfield< 31, 29 > format
static void setLevel(LogLevel ll)
Set the active log level.