[gnac/devel] Improve feedback handling, better categorization of the messages



commit 0923284bf86826497833be73ddbb221307117779
Author: David Joaquim <djoaquim src gnome org>
Date:   Sun Nov 29 11:33:55 2009 +0100

    Improve feedback handling, better categorization of the messages

 libgnac/libgnac-converter.c |   27 ++++++++++++++++++---------
 libgnac/libgnac-debug.c     |   16 ++++++++++++----
 libgnac/libgnac-debug.h     |   36 ++++++++++++++++++++++++++++++++++--
 libgnac/libgnac-gst.c       |    4 ++--
 src/gnac-main.c             |    8 ++++----
 5 files changed, 70 insertions(+), 21 deletions(-)
---
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index 05cf35f..ac71591 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -571,11 +571,13 @@ libgnac_converter_start_next(LibgnacConverter *self)
     uri = g_file_get_uri(item->source);
 
     g_signal_emit(self, signals[FILE_STARTED], 0, uri);
+    libgnac_info("File started %s", uri);
     libgnac_converter_item_run(item, &err);
     if (err)  {
       g_signal_emit(item->converter, signals[ERROR], 0, uri, err->message, err);
     }
 
+    // TODO why not retrieveing error ?
     tags = libgnac_metadata_extract(metadata, item->source, NULL);
     if (libgnac_metadata_tags_exist(tags, GST_TAG_DURATION, NULL))
     {
@@ -601,7 +603,7 @@ libgnac_converter_restart_current(LibgnacConverter *self)
 
   priv = LIBGNAC_CONVERTER_GET_PRIVATE(self);
 
-  libgnac_debug("restarting pipeline");
+  libgnac_info("Restarting pipeline");
 
   if (priv->current) 
   {
@@ -716,7 +718,7 @@ libgnac_converter_remove(LibgnacConverter  *self,
   } 
   else 
   {
-    libgnac_debug("item not found for file %s", uri);
+    libgnac_warning("File not found %s", uri);
     g_set_error(error,  
       LIBGNAC_ERROR, 
       LIBGNAC_ERROR_MISSING_FILE, 
@@ -750,6 +752,8 @@ libgnac_converter_start(LibgnacConverter  *self,
                         GError           **error)
 {
   LibgnacConverterPrivate *priv;
+  gchar *dbg_msg;
+
   g_return_if_fail(LIBGNAC_IS_CONVERTER(self));
   g_return_if_fail(error == NULL || *error == NULL);
 
@@ -767,6 +771,10 @@ libgnac_converter_start(LibgnacConverter  *self,
 
   g_signal_emit(self, signals[STARTED], 0);
 
+  dbg_msg = g_strdup_printf(_("Encoding pipeline: %s"), priv->audio_description);
+  libgnac_info(dbg_msg);
+  g_free(dbg_msg);
+
   if (!libgnac_converter_start_next(self))
   {
     g_signal_emit(self, signals[COMPLETION], 0);
@@ -861,6 +869,7 @@ libgnac_converter_item_build(LibgnacConverterItem  *item,
   g_return_if_fail(error == NULL || *error == NULL);
 
   /* is it a video file? */
+  // TODO why not passing error ?
   tags = libgnac_metadata_extract(metadata, item->source, NULL);
   if (tags && libgnac_metadata_tag_exists(tags, GNAC_TAG_HAS_VIDEO)) {
     has_video = TRUE;
@@ -868,7 +877,7 @@ libgnac_converter_item_build(LibgnacConverterItem  *item,
 
   libgnac_gst_build_pipeline(item, has_video, &err);
   if (err) {
-    libgnac_debug("Unable to build pipeline");
+    libgnac_warning("Unable to build pipeline");
     libgnac_gst_clean_pipeline(item);
     g_propagate_error(error, err);
   }
@@ -896,7 +905,7 @@ libgnac_converter_item_run(LibgnacConverterItem  *item,
   
   libgnac_gst_run(item, &err);
   if (err) {
-    libgnac_debug("Unable to run pipeline");
+    libgnac_warning("Unable to run pipeline");
     libgnac_gst_clean_pipeline(item);
     g_propagate_error(error, err);
     return;
@@ -922,7 +931,7 @@ libgnac_converter_item_stop(LibgnacConverterItem  *item,
     g_file_delete(item->destination, NULL, &err);
     if (err) {
       // Warning, but not critical
-      libgnac_debug("Unable to remove partial file");
+      libgnac_warning("Unable to remove partial file");
       g_clear_error(&err);
     }
   }
@@ -1063,7 +1072,7 @@ libgnac_converter_error_cb(GstBus      *bus,
           GError *err = NULL;
           g_file_delete(item->destination, NULL, &err);
           if (err) {
-            libgnac_debug("Unable to overwrite file %s: %s", uri, err->message);
+            libgnac_warning("Unable to overwrite file %s: %s", uri, err->message);
             g_clear_error(&err);
           }
           if (!err && libgnac_converter_restart_current(item->converter)) 
@@ -1099,15 +1108,15 @@ libgnac_converter_error_cb(GstBus      *bus,
     GError *err = NULL;
     g_file_delete(item->destination, NULL, &err);
     if (err) {
-      libgnac_debug("Unable to remove partial file %s: %s", uri, err->message);
+      libgnac_warning("Unable to remove partial file %s: %s", uri, err->message);
       g_clear_error(&err);
     }
     g_signal_emit(item->converter, signals[ERROR], 0, uri, 
                     _("An error occured during conversion"), error);
   }
 
-  libgnac_debug("Conversion failed:\n Object: %s\n Message: %s\n File: %s", 
-                  name, error->message, uri);
+  libgnac_warning("Conversion failed:\n\tFile: %s\n\tBin name: %s\n\tError message: %s", 
+                  uri, name, error->message);
 
   g_clear_error(&error);
   g_free(name);
diff --git a/libgnac/libgnac-debug.c b/libgnac/libgnac-debug.c
index 2c4b48d..e4e8a3d 100644
--- a/libgnac/libgnac-debug.c
+++ b/libgnac/libgnac-debug.c
@@ -53,7 +53,11 @@ libgnac_debug_real(const gchar *func,
 
 
 void
-libgnac_critical(const gchar *format, ...)
+libgnac_critical_real(const gchar *func,
+                const gchar *file,
+                const gint   line,
+                const gchar *format, 
+                ...)
 {
 	va_list args;
 	char buffer[1025];
@@ -62,12 +66,16 @@ libgnac_critical(const gchar *format, ...)
 	g_vsnprintf(buffer, 1024, format, args);
 	va_end(args);
 
-  g_printerr("[CRITICAL] %s\n", buffer);
+  g_printerr("[CRITICAL] %s:%d: %s\n", file, line, buffer);
 }
 
 
 void
-libgnac_warning(const gchar *format, ...)
+libgnac_warning_real(const gchar *func,
+                const gchar *file,
+                const gint   line,
+                const gchar *format, 
+                ...)
 {
 	va_list args;
 	char buffer[1025];
@@ -76,7 +84,7 @@ libgnac_warning(const gchar *format, ...)
 	g_vsnprintf(buffer, 1024, format, args);
 	va_end(args);
 
-  g_printerr("[WARNING] %s\n", buffer);
+  g_printerr("[WARNING] %s:%d: %s\n", file, line, buffer);
 }
 
 
diff --git a/libgnac/libgnac-debug.h b/libgnac/libgnac-debug.h
index ae94e63..255aea5 100644
--- a/libgnac/libgnac-debug.h
+++ b/libgnac/libgnac-debug.h
@@ -40,6 +40,28 @@
 #define libgnac_debug
 #endif
 
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define libgnac_warning(...) \
+        libgnac_warning_real (__func__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+#elif defined(__GNUC__) && __GNUC__ >= 3
+#define libgnac_warning(...) \
+        libgnac_warning_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
+#else
+#define libgnac_warning
+#endif
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define libgnac_critical(...) \
+        libgnac_critial_real (__func__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
+#elif defined(__GNUC__) && __GNUC__ >= 3
+#define libgnac_critical(...) \
+        libgnac_critical_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
+#else
+#define libgnac_critical
+#endif
+
+
+
 G_BEGIN_DECLS
 
 void 
@@ -50,10 +72,20 @@ libgnac_debug_real(const gchar *func,
                    ...);
 
 void
-libgnac_critical(const gchar *format, ...);
+libgnac_critical_real(const gchar *func,
+				              const gchar *file,
+				              gint         line,
+				              const gchar *format, 
+                      ...);
+
 
 void
-libgnac_warning(const gchar *format, ...);
+libgnac_warning_real(const gchar *func,
+				            const gchar *file,
+				            gint         line,
+				            const gchar *format, 
+                    ...);
+
 
 void
 libgnac_info(const gchar *format, ...);
diff --git a/libgnac/libgnac-gst.c b/libgnac/libgnac-gst.c
index feb259b..d2beb7e 100644
--- a/libgnac/libgnac-gst.c
+++ b/libgnac/libgnac-gst.c
@@ -109,7 +109,7 @@ libgnac_gst_pipeline_new(GError **error)
   GstElement *pipeline;
   pipeline = gst_pipeline_new("pipeline");
   if (!pipeline) {
-    libgnac_debug("Pipeline creation failed");
+    libgnac_warning("Pipeline creation failed");
     g_set_error(error,
         LIBGNAC_ERROR,
         LIBGNAC_ERROR_PIPELINE_CREATION,
@@ -336,7 +336,7 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
   /* output */
   libgnac_output_build_output(item, &encoder_error);
   if (encoder_error) {
-    libgnac_debug("Output creation failed");
+    libgnac_warning("Output creation failed");
     g_propagate_error(error, encoder_error);
     return;
   }
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 53c5b30..c6a90f2 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -96,7 +96,7 @@ gnac_change_state(GnacState new_state)
 {
   
 #ifdef GNOME_ENABLE_DEBUG
-  libgnac_debug("State changed to %s", states[new_state]);
+  libgnac_info("State changed to %s", states[new_state]);
 #endif
 
   prev_state = state;
@@ -488,13 +488,12 @@ gnac_add_file(GFile *file)
   GFileInfo *info;
   GtkFileFilterInfo filter_info;
 
-  libgnac_debug("Add file %s", g_file_get_uri(file));
-
+  libgnac_debug("Trying to add file %s", g_file_get_uri(file));
   info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
           G_FILE_QUERY_INFO_NONE, NULL, &error);
   if (error) {
     /* Error adding file */
-    libgnac_debug("Error adding file");
+    libgnac_debug("Unable to query file info");
     g_clear_error(&error);
     return;
   }
@@ -515,6 +514,7 @@ gnac_add_file(GFile *file)
     } else if (gtk_file_filter_filter(current_file_filter, &filter_info)) {
 
       /* No duplicate files */
+      libgnac_info("Add file %s", g_file_get_uri(file));
       libgnac_converter_add(converter, file, &error);
     }
   }



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