diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-10-18 14:35:15 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-10-19 10:26:01 +0300 |
commit | 4f26679b9e1c26314fdb92ca51452296ff8de785 (patch) | |
tree | ea7d2f9f4f7978da22aa2e95c971e632692f9e4c /gweb | |
parent | ab0c25458460cb2bb5f1e5b2549a8b9e81a59660 (diff) | |
download | connman-4f26679b9e1c26314fdb92ca51452296ff8de785.tar.gz connman-4f26679b9e1c26314fdb92ca51452296ff8de785.tar.bz2 connman-4f26679b9e1c26314fdb92ca51452296ff8de785.zip |
gresolv: Make debug func print more useful information
The file and function names are printed in debug prints.
Diffstat (limited to 'gweb')
-rw-r--r-- | gweb/gresolv.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gweb/gresolv.c b/gweb/gresolv.c index 8ff86190..88e2c029 100644 --- a/gweb/gresolv.c +++ b/gweb/gresolv.c @@ -115,18 +115,26 @@ struct _GResolv { gpointer debug_data; }; -static inline void debug(GResolv *resolv, const char *format, ...) +#define debug(resolv, format, arg...) \ + _debug(resolv, __FILE__, __func__, format, ## arg) + +static void _debug(GResolv *resolv, const char *file, const char *caller, + const char *format, ...) { char str[256]; va_list ap; + int len; if (resolv->debug_func == NULL) return; va_start(ap, format); - if (vsnprintf(str, sizeof(str), format, ap) > 0) - resolv->debug_func(str, resolv->debug_data); + if ((len = snprintf(str, sizeof(str), "%s:%s() resolv %p ", + file, caller, resolv)) > 0) { + if (vsnprintf(str + len, sizeof(str) - len, format, ap) > 0) + resolv->debug_func(str, resolv->debug_data); + } va_end(ap); } |