summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-10-18 11:35:19 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-10-19 07:26:29 (GMT)
commita6eb863566d5aeb588203d6c8dec2177ea9a6b72 (patch)
treec3f0b6fcf620d3a0f0db638df40f9b26e174666b
parentdcce19f15b225cc98341cd84f3d70d20b34a5406 (diff)
downloadconnman-a6eb863566d5aeb588203d6c8dec2177ea9a6b72.zip
connman-a6eb863566d5aeb588203d6c8dec2177ea9a6b72.tar.gz
connman-a6eb863566d5aeb588203d6c8dec2177ea9a6b72.tar.bz2
web: Make debug func print more useful information
The file and function name are printed in debug prints.
-rw-r--r--gweb/gweb.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c
index 4c2f95c..d35179a 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -128,18 +128,26 @@ struct _GWeb {
gpointer debug_data;
};
-static inline void debug(GWeb *web, const char *format, ...)
+#define debug(web, format, arg...) \
+ _debug(web, __FILE__, __func__, format, ## arg)
+
+static void _debug(GWeb *web, const char *file, const char *caller,
+ const char *format, ...)
{
char str[256];
va_list ap;
+ int len;
if (web->debug_func == NULL)
return;
va_start(ap, format);
- if (vsnprintf(str, sizeof(str), format, ap) > 0)
- web->debug_func(str, web->debug_data);
+ if ((len = snprintf(str, sizeof(str), "%s:%s() web %p ",
+ file, caller, web)) > 0) {
+ if (vsnprintf(str + len, sizeof(str) - len, format, ap) > 0)
+ web->debug_func(str, web->debug_data);
+ }
va_end(ap);
}