[libgtop] Add proper (and private) debug functions glibtop_debug*



commit 82ff91b74cc7418aec7dd725f119dd5eac715119
Author: Benoit Dejean <bdejean gmail com>
Date:   Sun Jun 21 20:52:11 2015 +0200

    Add proper (and private) debug functions glibtop_debug*

 include/glibtop/error.h |   10 ++++++++++
 sysdeps/common/error.c  |   19 +++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/include/glibtop/error.h b/include/glibtop/error.h
index f19e9bb..1ed7b40 100644
--- a/include/glibtop/error.h
+++ b/include/glibtop/error.h
@@ -46,6 +46,16 @@ void glibtop_warn (const char *format, ...) G_GNUC_PRINTF(1, 2);
 void glibtop_error_io (const char *format, ...) G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN;
 void glibtop_warn_io (const char *format, ...) G_GNUC_PRINTF(1, 2);
 
+/* FIXME: C99 */
+#define glibtop_debug(fmt, ...)                                                \
+       G_STMT_START {                                                  \
+       if (LIBGTOP_ENABLE_DEBUG)                                       \
+               glibtop_debug_r(glibtop_global_server, fmt, __VA_ARGS__); \
+       G_STMT_END
+
+void glibtop_debug_vr (glibtop *server, const char *format, va_list args);
+void glibtop_debug_r (glibtop *server, const char *format, ...) G_GNUC_PRINTF(2, 3);
+
 G_END_DECLS
 
 #endif
diff --git a/sysdeps/common/error.c b/sysdeps/common/error.c
index d6e9438..a7a4581 100644
--- a/sysdeps/common/error.c
+++ b/sysdeps/common/error.c
@@ -134,6 +134,25 @@ glibtop_warn_io_r (glibtop *server, const char *format, ...)
 
 
 void
+glibtop_debug_vr (glibtop *server, const char *format, va_list args)
+{
+       print_server_name (server);
+       vfprintf (stderr, format, args);
+       fputc('\n', stderr);
+}
+
+void
+glibtop_debug_r (glibtop *server, const char *format, ...)
+{
+       va_list args;
+
+       va_start (args, format);
+       glibtop_debug_vr (server, format, args);
+       va_end (args);
+}
+
+
+void
 glibtop_error (const char *format, ...)
 {
        va_list args;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]