summaryrefslogtreecommitdiff
path: root/wocky/wocky-debug-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'wocky/wocky-debug-internal.h')
-rw-r--r--wocky/wocky-debug-internal.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/wocky/wocky-debug-internal.h b/wocky/wocky-debug-internal.h
new file mode 100644
index 0000000..3880519
--- /dev/null
+++ b/wocky/wocky-debug-internal.h
@@ -0,0 +1,86 @@
+#if !defined (WOCKY_COMPILATION)
+# error "This is an internal header."
+#endif
+
+#ifndef WOCKY_DEBUG_INTERNAL_H
+#define WOCKY_DEBUG_INTERNAL_H
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "wocky-debug.h"
+#include "wocky-stanza.h"
+
+G_BEGIN_DECLS
+
+#ifdef ENABLE_DEBUG
+
+void wocky_debug_set_flags_from_env (void);
+gboolean wocky_debug_flag_is_set (WockyDebugFlags flag);
+
+void wocky_debug_valist (WockyDebugFlags flag,
+ const gchar *format, va_list args);
+
+void wocky_debug (WockyDebugFlags flag, const gchar *format, ...)
+ G_GNUC_PRINTF (2, 3);
+void wocky_debug_stanza (WockyDebugFlags flag, WockyStanza *stanza,
+ const gchar *format, ...)
+ G_GNUC_PRINTF (3, 4);
+void wocky_debug_node_tree (WockyDebugFlags flag, WockyNodeTree *tree,
+ const gchar *format, ...)
+ G_GNUC_PRINTF (3, 4);
+
+#ifdef DEBUG_FLAG
+
+#define DEBUG(format, ...) \
+ wocky_debug (DEBUG_FLAG, "%s: %s: " format, G_STRFUNC, G_STRLOC, \
+ ##__VA_ARGS__)
+
+#define DEBUG_STANZA(stanza, format, ...) \
+ wocky_debug_stanza (DEBUG_FLAG, stanza, "%s: " format, G_STRFUNC,\
+ ##__VA_ARGS__)
+
+#define DEBUG_NODE_TREE(tree, format, ...) \
+ wocky_debug_node_tree (DEBUG_FLAG, tree, "%s: " format, G_STRFUNC,\
+ ##__VA_ARGS__)
+
+#define DEBUGGING wocky_debug_flag_is_set(DEBUG_FLAG)
+
+#endif /* DEBUG_FLAG */
+
+#else /* ENABLE_DEBUG */
+
+#ifdef DEBUG_FLAG
+
+static inline void
+DEBUG (
+ const gchar *format,
+ ...)
+{
+ /* blah blah blah */
+}
+
+static inline void
+DEBUG_STANZA (WockyStanza *stanza,
+ const gchar *format,
+ ...)
+{
+}
+
+static inline void
+DEBUG_NODE_TREE (WockyNodeTree *tree,
+ const gchar *format,
+ ...)
+{
+}
+
+#define DEBUGGING 0
+
+#endif /* DEBUG_FLAG */
+
+#endif /* ENABLE_DEBUG */
+
+G_END_DECLS
+
+#endif