[rhythmbox] rework rb_debug to allow it to be called via introspection
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] rework rb_debug to allow it to be called via introspection
- Date: Tue, 1 Feb 2011 13:21:20 +0000 (UTC)
commit f258d410fa5ef5e410b3405057a240b19aca9c65
Author: Jonathan Matthew <jonathan d14n org>
Date: Tue Feb 1 20:57:26 2011 +1000
rework rb_debug to allow it to be called via introspection
backends/gstreamer/rb-player-gst-xfade.c | 2 +-
lib/rb-debug.c | 50 ++++++++++++++++++++++-------
lib/rb-debug.h | 9 ++++-
podcast/test-podcast-parse.c | 12 +++---
4 files changed, 52 insertions(+), 21 deletions(-)
---
diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c
index 3ac7b56..9b49475 100644
--- a/backends/gstreamer/rb-player-gst-xfade.c
+++ b/backends/gstreamer/rb-player-gst-xfade.c
@@ -1838,7 +1838,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
}
details = gst_structure_to_string (s);
- rb_debug_real ("check-imperfect", __FILE__, __LINE__, TRUE, "%s: %s", uri, details);
+ rb_debug_realf ("check-imperfect", __FILE__, __LINE__, TRUE, "%s: %s", uri, details);
g_free (details);
} else if (strcmp (name, "redirect") == 0) {
const char *uri = gst_structure_get_string (s, "new-location");
diff --git a/lib/rb-debug.c b/lib/rb-debug.c
index f1ed2c0..44d54ae 100644
--- a/lib/rb-debug.c
+++ b/lib/rb-debug.c
@@ -90,12 +90,44 @@ rb_debug_matches (const char *func,
* include one.
*/
+static void
+_rb_debug_print (const char *func, const char *file, const int line, gboolean newline, const char *buffer)
+{
+ char str_time[255];
+ time_t the_time;
+
+ time (&the_time);
+ strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
+
+ g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : "(%s) [%p] [%s] %s:%d: %s",
+ str_time, g_thread_self (), func, file, line, buffer);
+}
+
/**
* rb_debug_real:
* @func: function name
* @file: file name
* @line: line number
* @newline: if TRUE, add a newline to the output
+ * @message: the debug message
+ *
+ * If the debug output settings match the function or file names,
+ * the debug message will be formatted and written to standard error.
+ */
+void
+rb_debug_real (const char *func, const char *file, const int line, gboolean newline, const char *message)
+{
+ if (rb_debug_matches (func, file)) {
+ _rb_debug_print (func, file, line, newline, message);
+ }
+}
+
+/**
+ * rb_debug_realf:
+ * @func: function name
+ * @file: file name
+ * @line: line number
+ * @newline: if TRUE, add a newline to the output
* @format: printf style format specifier
* @Varargs: substitution values for @format
*
@@ -103,16 +135,14 @@ rb_debug_matches (const char *func,
* the debug message will be formatted and written to standard error.
*/
void
-rb_debug_real (const char *func,
- const char *file,
- const int line,
- gboolean newline,
- const char *format, ...)
+rb_debug_realf (const char *func,
+ const char *file,
+ const int line,
+ gboolean newline,
+ const char *format, ...)
{
va_list args;
char buffer[1025];
- char str_time[255];
- time_t the_time;
if (!rb_debug_matches (func, file))
return;
@@ -123,11 +153,7 @@ rb_debug_real (const char *func,
va_end (args);
- time (&the_time);
- strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
-
- g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : "(%s) [%p] [%s] %s:%d: %s",
- str_time, g_thread_self (), func, file, line, buffer);
+ _rb_debug_print (func, file, line, newline, buffer);
}
/**
diff --git a/lib/rb-debug.h b/lib/rb-debug.h
index dd96576..bcdbe48 100644
--- a/lib/rb-debug.h
+++ b/lib/rb-debug.h
@@ -35,9 +35,9 @@
G_BEGIN_DECLS
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#define rb_debug(...) rb_debug_real (__func__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+#define rb_debug(...) rb_debug_realf (__func__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
#elif defined(__GNUC__) && __GNUC__ >= 3
-#define rb_debug(...) rb_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+#define rb_debug(...) rb_debug_realf (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
#else
#define rb_debug
#endif
@@ -51,6 +51,11 @@ void rb_debug_real (const char *func,
const char *file,
int line,
gboolean newline,
+ const char *message);
+void rb_debug_realf (const char *func,
+ const char *file,
+ int line,
+ gboolean newline,
const char *format, ...) G_GNUC_PRINTF (5, 6);
char **rb_debug_get_args (void);
diff --git a/podcast/test-podcast-parse.c b/podcast/test-podcast-parse.c
index f45431a..7ed5907 100644
--- a/podcast/test-podcast-parse.c
+++ b/podcast/test-podcast-parse.c
@@ -38,7 +38,7 @@
static gboolean debug = FALSE;
-void rb_debug_real (const char *func,
+void rb_debug_realf (const char *func,
const char *file,
int line,
gboolean newline,
@@ -46,11 +46,11 @@ void rb_debug_real (const char *func,
/* For the benefit of the podcast parsing code */
void
-rb_debug_real (const char *func,
- const char *file,
- int line,
- gboolean newline,
- const char *format, ...)
+rb_debug_realf (const char *func,
+ const char *file,
+ int line,
+ gboolean newline,
+ const char *format, ...)
{
va_list args;
char buffer[1025];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]