radare2/libr/util/assert.c
Riccardo Schirone 3d5fac61f6 assert: use R2_ASSERT_STDOUT instead of ASSERT_STDOUT
In this way Travis script (travis-extract-var.sh) will automatically
pass the var to the docker container. Also, it makes the macro name more
consistent with all the others.
2018-10-29 16:01:26 +01:00

36 lines
971 B
C

#include <r_util.h>
#ifdef R2_ASSERT_STDOUT
static void stdout_log(const char *output, const char *funcname, const char *filename,
ut32 lineno, RLogLevel level, const char *tag, const char *fmtstr, ...) {
printf ("%s", output);
}
static void print_message(RLogLevel level, const char *fmt, va_list args) {
r_log_add_callback (stdout_log);
R_VLOG (level, NULL, fmt, args);
r_log_del_callback (stdout_log);
}
#else
static void print_message(RLogLevel level, const char *fmt, va_list args) {
R_VLOG (level, NULL, fmt, args);
}
#endif
/*
* It prints a message to the log and it provides a single point of entrance in
* case of debugging. All r_return_* functions call this.
*/
R_API void r_assert_log(RLogLevel level, const char *fmt, ...) {
va_list args;
va_start (args, fmt);
print_message (level, fmt, args);
va_end (args);
char *env = r_sys_getenv ("R_DEBUG_ASSERT");
if (env) {
if (*env && atoi (env)) {
r_sys_breakpoint ();
}
free (env);
}
}