21 #ifndef __EDELIB_DEBUG_H__
22 #define __EDELIB_DEBUG_H__
24 #include "edelib-global.h"
36 EDELIB_API
void edelib_logv(
const char *domain,
int type,
const char *fmt, va_list args);
37 EDELIB_API
void edelib_log(
const char *domain,
int type,
const char *fmt, ...);
45 EDELIB_ERROR_MESSAGE_DEBUG,
46 EDELIB_ERROR_MESSAGE_WARNING,
47 EDELIB_ERROR_MESSAGE_FATAL
48 } EdelibErrorMessageType;
53 EDELIB_API
void edelib_error_message_handler_install(
void (*)(
int t,
const char* domain,
const char* msg));
63 #define E_LOG_DOMAIN ((char*)0)
67 #define _E_FUNCTION_NAME __PRETTY_FUNCTION__
69 #define _E_FUNCTION_NAME "<unknown>"
93 #ifdef EDELIB_HAVE_ISO_VARARGS
94 #define E_DEBUG(...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_DEBUG, __VA_ARGS__)
95 #define E_WARNING(...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_WARNING, __VA_ARGS__)
96 #define E_FATAL(...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_FATAL, __VA_ARGS__)
97 #elif defined(EDELIB_HAVE_GNUC_VARARGS)
98 #define E_DEBUG(format...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_DEBUG, format)
99 #define E_WARNING(format...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_WARNING, format)
100 #define E_FATAL(format...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_FATAL, format)
102 void E_DEBUG(
const char *fmt, ...);
104 void E_FATAL(
const char *fmt, ...);
115 #define E_ASSERT(expr)
117 #define E_ASSERT(expr) \
120 edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_FATAL, "Assertion failed: \"%s\" in %s (%d), function: \"%s\"\n", \
121 #expr, __FILE__, __LINE__, _E_FUNCTION_NAME); \
125 #define _E_STRLOC_STRINGIFY(arg) _E_STRLOC_STRINGIFY_ARG(arg)
126 #define _E_STRLOC_STRINGIFY_ARG(content) #content
134 #define E_STRLOC __FILE__ ":" _E_STRLOC_STRINGIFY(__LINE__)
152 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
153 #define _E_BOOLEAN_EXPR(expr) \
155 int _edelib_boolean_var_; \
157 _edelib_boolean_var_ = 1; \
159 _edelib_boolean_var_ = 0; \
160 _edelib_boolean_var_; \
163 #define E_LIKELY(expr) (__builtin_expect(_E_BOOLEAN_EXPR(expr), 1))
164 #define E_UNLIKELY(expr) (__builtin_expect(_E_BOOLEAN_EXPR(expr), 0))
166 #define E_LIKELY(expr) (expr)
167 #define E_UNLIKELY(expr) (expr)
178 #define E_RETURN_IF_FAIL(expr) \
180 if E_LIKELY(expr) { } \
182 E_WARNING(E_STRLOC ": Condition '%s' failed\n", #expr); \
194 #define E_RETURN_VAL_IF_FAIL(expr, val) \
196 if E_LIKELY(expr) { } \
198 E_WARNING(E_STRLOC ": Condition '%s' failed\n", #expr); \
205 #define EDEBUG E_DEBUG
206 #define EWARNING E_WARNING
207 #define EFATAL E_FATAL
208 #define EASSERT E_ASSERT
209 #define ESTRLOC E_STRLOC
#define E_FATAL(...)
Definition: Debug.h:96
#define E_DEBUG(...)
Definition: Debug.h:94
#define E_WARNING(...)
Definition: Debug.h:95