27 #define LOGGING_HPP_ 1
55 #define LOG_WITH_NAME_N(DBG_NAME, VERBOSE, EXPR) \
57 if (DEBUG_COND_WITH_NAME_N( (DBG_NAME) , (VERBOSE) )) { \
58 cacao::OStream stream = cacao::dbg(); \
60 if (cacao::Debug::thread_enabled) { \
61 stream << "LOG: " << cacao::threadid << " "; \
64 if (cacao::Debug::prefix_enabled) { \
65 stream << setprefix(DBG_NAME, cacao::log_color()); \
68 { stream << EXPR ; } \
74 void set_log_file(FILE *file);
77 void set_log_color(
Color color);
82 #else // defined(ENABLE_LOGGING)
84 #define LOG_WITH_NAME_N(DBG_NAME, VERBOSE, STMT) do { } while(0)
86 #endif // defined(ENABLE_LOGGING)
88 #define LOG_WITH_NAME(DBG_NAME, STMT) LOG_WITH_NAME_N(DBG_NAME, 0, STMT)
89 #define LOG_N(VERBOSE, STMT) LOG_WITH_NAME_N(DEBUG_NAME, VERBOSE, STMT)
91 #define LOG(STMT) LOG_N(0, STMT)
92 #define LOG1(STMT) LOG_N(1, STMT)
93 #define LOG2(STMT) LOG_N(2, STMT)
94 #define LOG3(STMT) LOG_N(3, STMT)
96 #define WARNING_MSG(EXPR_SHORT, EXPR_LONG) \
98 cacao::OStream stream = cacao::err(); \
100 { stream << cacao::BoldWhite << __FILE__ << ":" << __LINE__ << ": ";} \
101 { stream << cacao::BoldMagenta << "warning: " ; } \
102 { stream << cacao::BoldWhite << EXPR_SHORT << cacao::reset_color ; } \
103 { stream << cacao::nl << EXPR_LONG << cacao::nl; } \
107 #define assert_msg(COND, EXPR) \
110 cacao::OStream stream = cacao::err(); \
112 { stream << cacao::BoldRed << "assertion failed: " ; } \
113 { stream << cacao::BoldWhite<<"`"#COND"'"<< cacao::reset_color; } \
114 { stream << cacao::nl << EXPR << cacao::nl ; } \
120 #define assert_msg(COND, EXPR)
124 #define ERROR_MSG(EXPR_SHORT, EXPR_LONG) \
126 cacao::OStream stream = cacao::err(); \
128 { stream << cacao::BoldRed << "error: " ; } \
129 { stream << cacao::BoldWhite << EXPR_SHORT << cacao::reset_color ; } \
130 { stream << cacao::nl << EXPR_LONG << cacao::nl; } \
133 #define ABORT_MSG(EXPR_SHORT, EXPR_LONG) \
135 ERROR_MSG(EXPR_SHORT, EXPR_LONG); \
139 #define SHOULDNOTREACH_MSG(EXPR_LONG) \
141 ERROR_MSG("should not reach", EXPR_LONG); \
145 #define UNIMPLEMENTED_MSG(EXPR_LONG) \
147 ERROR_MSG("not implemented yet", EXPR_LONG); \
164 void log_vprint(
const char *text, va_list ap);
170 #define log_text(s) log_println("%s", (s))
171 #define dolog log_println
180 #endif // LOGGING_HPP_
void log_message_method(const char *msg, methodinfo *m)
void log_message_class_message_class(const char *msg1, classinfo *c1, const char *msg2, classinfo *c2)
void log_println(const char *text,...)
void log_print(const char *text,...)
void log_vprint(const char *text, va_list ap)
void log_init(const char *fname)
void log_message_utf(const char *msg, Utf8String u)
OStream & dbg()
The default destination for logging messages.
void log_message_class(const char *msg, classinfo *c)