/** * Print a formatted string to stdout, using va_list * * @param fmt Formatted string * @param ap Variable-arguments list * * @return The number of characters printed, or -1 if error */ int re_vprintf(const char *fmt, va_list ap) { /* ytam edit */ // va_start(ap,fmt); //__android_log_vprint(ANDROID_LOG_INFO, "re", fmt, ap); // __android_log_write(ANDROID_LOG_INFO, "re", fmt); // va_end(ap); /* end edit */ return re_vfprintf(stdout, fmt, ap); }
/** * Print a formatted string to a file stream * * @param stream File stream for output * @param fmt Formatted string * * @return The number of characters printed, or -1 if error */ int re_fprintf(FILE *stream, const char *fmt, ...) { va_list ap; int n; va_start(ap, fmt); n = re_vfprintf(stream, fmt, ap); va_end(ap); return n; }
/* NOTE: This function should not allocate memory */ static void dbg_vprintf(int level, const char *fmt, va_list ap) { if (level > dbg.level) return; /* Print handler? */ if (dbg.ph) return; dbg_lock(); if (dbg.flags & DBG_ANSI) { switch (level) { case DBG_WARNING: (void)re_fprintf(stderr, "\x1b[31m"); /* Red */ break; case DBG_NOTICE: (void)re_fprintf(stderr, "\x1b[33m"); /* Yellow */ break; case DBG_INFO: (void)re_fprintf(stderr, "\x1b[32m"); /* Green */ break; default: break; } } if (dbg.flags & DBG_TIME) { const uint64_t ticks = tmr_jiffies(); if (0 == dbg.tick) dbg.tick = tmr_jiffies(); (void)re_fprintf(stderr, "[%09llu] ", ticks - dbg.tick); } (void)re_vfprintf(stderr, fmt, ap); if (dbg.flags & DBG_ANSI && level < DBG_DEBUG) (void)re_fprintf(stderr, "\x1b[;m"); dbg_unlock(); }