Add debug function/macro, derived from warn
This commit is contained in:
parent
c183588ba1
commit
f2e9217978
|
@ -73,6 +73,19 @@ _warn(int line, const char *fct, const char *fmt, ...)
|
|||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/** Print debug message on stderr.
|
||||
*/
|
||||
void
|
||||
_debug(int line, const char *fct, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
fprintf(stderr, "D: awesome: %s:%d: ", fct, line);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/** \brief safe limited strcpy.
|
||||
*
|
||||
* Copies at most min(<tt>n-1</tt>, \c l) characters from \c src into \c dst,
|
||||
|
|
|
@ -321,6 +321,12 @@ void _warn(int, const char *, const char *, ...)
|
|||
|
||||
const char *a_current_time_str(void);
|
||||
|
||||
#define debug(string, ...) _debug(__LINE__, \
|
||||
__FUNCTION__, \
|
||||
string, ## __VA_ARGS__)
|
||||
void _debug(int, const char *, const char *, ...)
|
||||
__attribute__ ((format(printf, 3, 4)));
|
||||
|
||||
void a_exec(const char *);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue