From 342f4e929888c0aaa088e39fb98a74957bf45fa7 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 12 Jan 2010 19:09:36 +0100 Subject: Refactor and unify internal debug system for ease of use and verbosity This introduces a new debug_info macro which automatically prints the calling function, file and line number information instead of having that information passed to every old log_debug_msg call. --- src/debug.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/debug.h') diff --git a/src/debug.h b/src/debug.h index 398508e..f99089d 100644 --- a/src/debug.h +++ b/src/debug.h @@ -1,6 +1,6 @@ /* * debug.h - * contains utilitary methos for logging and debugging + * contains utilitary functions for debugging * * Copyright (c) 2008 Jonathan Beck All Rights Reserved. * @@ -24,8 +24,20 @@ #include -G_GNUC_INTERNAL inline void log_debug_msg(const char *format, ...); -G_GNUC_INTERNAL inline void log_debug_buffer(const char *data, const int length); -G_GNUC_INTERNAL inline void dump_debug_buffer(const char *file, const char *data, const int length); +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && !defined(STRIP_DEBUG_CODE) +#define debug_info(...) debug_info_real (__func__, __FILE__, __LINE__, __VA_ARGS__) +#elif defined(__GNUC__) && __GNUC__ >= 3 && !defined(STRIP_DEBUG_CODE) +#define debug_info(...) debug_info_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) +#else +#define debug_info(...) +#endif + +G_GNUC_INTERNAL inline void debug_info_real(const char *func, + const char *file, + int line, + const char *format, ...); + +G_GNUC_INTERNAL inline void debug_buffer(const char *data, const int length); +G_GNUC_INTERNAL inline void debug_buffer_to_file(const char *file, const char *data, const int length); #endif -- cgit v1.1-32-gdbae