39 #ifndef picox_core_detail_xdebug_h_ 40 #define picox_core_detail_xdebug_h_ 63 typedef void(*
XAssertionFailedFunc)(
const char* expr,
const char* msg,
const char* func,
const char* file,
int line);
110 #define X_LOG_LEVEL_ERR (1) 111 #define X_LOG_LEVEL_WARN (2) 112 #define X_LOG_LEVEL_NOTI (3) 113 #define X_LOG_LEVEL_INFO (4) 114 #define X_LOG_LEVEL_VERB (5) 115 #define X_LOG_LEVEL X_CONF_LOG_LEVEL 129 #define X_ANSI_COLOR_BLACK "\x1b[1;30m" 130 #define X_ANSI_COLOR_RED "\x1b[1;31m" 131 #define X_ANSI_COLOR_GREEN "\x1b[1;32m" 132 #define X_ANSI_COLOR_YELLOW "\x1b[1;33m" 133 #define X_ANSI_COLOR_BLUE "\x1b[1;34m" 134 #define X_ANSI_COLOR_MAGENTA "\x1b[1;35m" 135 #define X_ANSI_COLOR_CYAN "\x1b[1;36m" 136 #define X_ANSI_COLOR_WHITE "\x1b[1;37m" 137 #define X_ANSI_COLOR_RESET "\x1b[0m" 140 #if X_CONF_USE_ANSI_COLOR_LOG != 0 141 #define X_COLOR_BLACK X_ANSI_COLOR_BLACK 142 #define X_COLOR_RED X_ANSI_COLOR_RED 143 #define X_COLOR_GREEN X_ANSI_COLOR_GREEN 144 #define X_COLOR_YELLOW X_ANSI_COLOR_YELLOW 145 #define X_COLOR_BLUE X_ANSI_COLOR_BLUE 146 #define X_COLOR_MAGENTA X_ANSI_COLOR_MAGENTA 147 #define X_COLOR_CYAN X_ANSI_COLOR_CYAN 148 #define X_COLOR_WHITE X_ANSI_COLOR_WHITE 149 #define X_COLOR_RESET X_ANSI_COLOR_RESET 151 #define X_COLOR_BLACK 153 #define X_COLOR_GREEN 154 #define X_COLOR_YELLOW 156 #define X_COLOR_MAGENTA 158 #define X_COLOR_WHITE 159 #define X_COLOR_RESET 181 #if (X_CONF_USE_DYNAMIC_LOG_SUPPRESS != 0) || (X_LOG_LEVEL >= X_LOG_LEVEL_VERB) 182 #define X_LOG_VERB(args) x_verb_printlog args 183 #define X_LOG_HEXDUMP_VERB(args) x_verb_hexdump args 185 #define X_LOG_VERB(args) (void)0 186 #define X_LOG_HEXDUMP_VERB(args) (void)0 190 #if (X_CONF_USE_DYNAMIC_LOG_SUPPRESS != 0) || (X_LOG_LEVEL >= X_LOG_LEVEL_INFO) 191 #define X_LOG_INFO(args) x_info_printlog args 192 #define X_LOG_HEXDUMP_INFO(args) x_info_hexdump args 194 #define X_LOG_INFO(args) (void)0 195 #define X_LOG_HEXDUMP_INFO(args) (void)0 199 #if (X_CONF_USE_DYNAMIC_LOG_SUPPRESS != 0) || (X_LOG_LEVEL >= X_LOG_LEVEL_NOTI) 200 #define X_LOG_NOTI(args) x_noti_printlog args 201 #define X_LOG_HEXDUMP_NOTI(args) x_noti_hexdump args 203 #define X_LOG_NOTI(args) (void)0 204 #define X_LOG_HEXDUMP_NOTI(args) (void)0 208 #if (X_CONF_USE_DYNAMIC_LOG_SUPPRESS != 0) || (X_LOG_LEVEL >= X_LOG_LEVEL_WARN) 209 #define X_LOG_WARN(args) x_warn_printlog args 210 #define X_LOG_HEXDUMP_WARN(args) x_warn_hexdump args 212 #define X_LOG_WARN(args) (void)0 213 #define X_LOG_HEXDUMP_WARN(args) (void)0 217 #if (X_CONF_USE_DYNAMIC_LOG_SUPPRESS != 0) || (X_LOG_LEVEL >= X_LOG_LEVEL_ERR) 218 #define X_LOG_ERR(args) x_err_printlog args 219 #define X_LOG_HEXDUMP_ERR(args) x_err_hexdump args 221 #define X_LOG_ERR(args) (void)0 222 #define X_LOG_HEXDUMP_ERR(args) (void)0 238 #define X_DEFAULT_ASSERT(expr) X_DEFAULT_ASSERT_MSG(expr, NULL) 243 #define X_DEFAULT_ASSERT_MSG(expr, msg) ((expr) ? (void)0 : x_assertion_failed(#expr, msg, X_FUNC, __FILE__, __LINE__)) 246 #if (X_CONF_NDEBUG == 0) 247 #define X_ASSERT(expr) X_DEFAULT_ASSERT(expr) 248 #define X_ASSERT_MSG(expr, msg) X_DEFAULT_ASSERT_MSG(expr, msg) 250 #define X_ASSERT(expr) (void)0 251 #define X_ASSERT_MSG(expr, msg) (void)0 258 #if X_CONF_USE_ASSERT_SELF != 0 259 #define X_ASSERT_SELF(expr) X_ASSERT(expr) 261 #define X_ASSERT_SELF(expr) (void)0 268 #if X_CONF_USE_ASSERT_ARG != 0 269 #define X_ASSERT_ARG(expr) X_ASSERT(expr) 271 #define X_ASSERT_ARG(expr) (void)0 278 #if X_CONF_USE_ASSERT_NULL != 0 279 #define X_ASSERT_NULL(expr) X_ASSERT(expr) 281 #define X_ASSERT_NULL(expr) (void)0 288 #if X_CONF_USE_ASSERT_TAG 289 #define X_ASSERT_TAG(expr) X_ASSERT(expr) 291 #define X_ASSERT_TAG(expr) (void)0 298 #if X_CONF_USE_ASSERT_ENUM 299 #define X_ASSERT_ENUM(expr) X_ASSERT(expr) 301 #define X_ASSERT_ENUM(expr) (void)0 308 #if X_CONF_USE_DETECT_MALLOC_NULL != 0 309 #define X_ASSERT_MALLOC_NULL(expr) X_ASSERT(expr) 311 #define X_ASSERT_MALLOC_NULL(expr) (void)0 318 #define X_ABORT(msg) X_ASSERT_MSG(0, msg) 324 #define X_ABORT_DEFAULT default: X_ABORT("Runtime error"); break 330 #define X_EXIT(return_code) X_ABORT("exit:" #return_code) 341 #define X_VERB_COLOR "" 342 #define X_INFO_COLOR X_COLOR_GREEN 343 #define X_NOTI_COLOR X_COLOR_MAGENTA 344 #define X_WARN_COLOR X_COLOR_YELLOW 345 #define X_ERR_COLOR X_COLOR_RED 346 #define X_VERB_HEADER X_VERB_COLOR X_CONF_VERB_HEADER X_COLOR_RESET 347 #define X_INFO_HEADER X_INFO_COLOR X_CONF_INFO_HEADER X_COLOR_RESET 348 #define X_NOTI_HEADER X_NOTI_COLOR X_CONF_NOTI_HEADER X_COLOR_RESET 349 #define X_WARN_HEADER X_WARN_COLOR X_CONF_WARN_HEADER X_COLOR_RESET 350 #define X_ERR_HEADER X_ERR_COLOR X_CONF_ERR_HEADER X_COLOR_RESET 357 int x_set_log_level(
int level);
358 void x_hexdump(
const void* src,
size_t len,
size_t cols);
368 void x_verb_printlog(
const char* tag,
const char* fmt, ...);
369 void x_info_printlog(
const char* tag,
const char* fmt, ...);
370 void x_noti_printlog(
const char* tag,
const char* fmt, ...);
371 void x_warn_printlog(
const char* tag,
const char* fmt, ...);
372 void x_err_printlog(
const char* tag,
const char* fmt, ...);
373 void x_verb_hexdump(
const char* tag,
const void* src,
size_t len,
size_t cols,
const char* fmt, ...);
374 void x_info_hexdump(
const char* tag,
const void* src,
size_t len,
size_t cols,
const char* fmt, ...);
375 void x_noti_hexdump(
const char* tag,
const void* src,
size_t len,
size_t cols,
const char* fmt, ...);
376 void x_warn_hexdump(
const char* tag,
const void* src,
size_t len,
size_t cols,
const char* fmt, ...);
377 void x_err_hexdump(
const char* tag,
const void* src,
size_t len,
size_t cols,
const char* fmt, ...);
394 #endif // picox_core_detail_xdebug_h_ XAssertionFailedFunc x_post_assertion_failed
x_assertion_failedの呼び出し後に呼びされる関数のポインタです
Definition: xdebug.c:65
void(* XAssertionFailedFunc)(const char *expr, const char *msg, const char *func, const char *file, int line)
アサーションに失敗した時に呼び出される関数のポインタ型です
Definition: xdebug.h:63
XAssertionFailedFunc x_assertion_failed
アサーション失敗時に呼びされる関数のポインタです
Definition: xdebug.c:66
XAssertionFailedFunc x_pre_assertion_failed
x_assertion_failedの呼び出し前に呼びされる関数のポインタです
Definition: xdebug.c:64