[sound-juicer] Add logging for metadata retrieval



commit 248ba2826c0fbe93708dcfed87f0e00d6bbef806
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Tue Apr 5 14:06:30 2016 +0100

    Add logging for metadata retrieval
    
    Add some logging for debugging metadata retrieval. This is turned on by
    setting G_MESSAGES_DEBUG=sj-metadata. This should hopefully provide some
    useful information when users file bug reports.

 README                               |    5 ++---
 libjuicer/sj-metadata-gvfs.c         |    4 ++++
 libjuicer/sj-metadata-musicbrainz5.c |   13 ++++++++++---
 3 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/README b/README
index 15ef73e..0286e8a 100644
--- a/README
+++ b/README
@@ -13,9 +13,8 @@ Requirements:
 Do the usual configure/make/make install malarky, and run "sound-juicer" in
 $(prefix)/bin or "Sound Juicer CD Extractor" in Applications -> Sound & Video.
 
-If the CD lookup is returning weird data, export MUSICBRAINZ_DEBUG
-before running sound-juicer to turn debugging on in MusicBrainz. This
-will show the chat between Sound Juicer and the MusicBrainz servers.
+If the CD lookup is returning weird data, export G_MESSAGES_DEBUG=sj-metadata
+before running sound-juicer to turn metadata debugging messages.
 
 
 Common Problems
diff --git a/libjuicer/sj-metadata-gvfs.c b/libjuicer/sj-metadata-gvfs.c
index 15767c4..787ece7 100644
--- a/libjuicer/sj-metadata-gvfs.c
+++ b/libjuicer/sj-metadata-gvfs.c
@@ -16,6 +16,8 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#define G_LOG_DOMAIN "sj-metadata"
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
@@ -108,9 +110,11 @@ gvfs_list_albums (SjMetadata *metadata, char **url, GCancellable *cancellable, G
   /* Get the album metadata */
   str = g_file_info_get_attribute_string (info, "xattr::org.gnome.audio.title");
   if (!sj_str_is_empty (str)) {
+    g_info ("Have CD TEXT");
     album->metadata_source = SOURCE_CDTEXT;
     album->title = g_strdup (str);
   } else {
+    g_info ("No CD TEXT");
     album->metadata_source = SOURCE_FALLBACK;
     album->title = g_strdup (_("Unknown Title"));
   }
diff --git a/libjuicer/sj-metadata-musicbrainz5.c b/libjuicer/sj-metadata-musicbrainz5.c
index ed31b8f..ebd8261 100644
--- a/libjuicer/sj-metadata-musicbrainz5.c
+++ b/libjuicer/sj-metadata-musicbrainz5.c
@@ -18,6 +18,8 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#define G_LOG_DOMAIN "sj-metadata"
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
@@ -181,7 +183,7 @@ print_musicbrainz_query_error (SjMetadataMusicbrainz5 *self,
   len =  mb5_query_get_lasterrormessage (priv->mb, NULL, 0) + 1;
   message = g_malloc (len);
   mb5_query_get_lasterrormessage (priv->mb, message, len);
-  g_warning ("No Musicbrainz metadata for %s %s, http code %d, %s",
+  g_info ("No Musicbrainz metadata for %s %s, http code %d, %s",
              entity, id, code, message);
   g_free (message);
 }
@@ -203,6 +205,8 @@ query_musicbrainz (SjMetadataMusicbrainz5  *self,
   SjMetadataMusicbrainz5Private *priv = GET_PRIVATE (self);
   gint64 t;
 
+  g_info ("Querying %s %s", entity, id);
+
   while (TRUE) {
     if (g_cancellable_set_error_if_cancelled (cancellable, error))
       return NULL;
@@ -223,6 +227,9 @@ query_musicbrainz (SjMetadataMusicbrainz5  *self,
     if (metadata != NULL || ++count == 5 ||
         mb5_query_get_lasthttpcode (priv->mb) != 503)
       break;
+    g_info ("Retrying %d sleeping for %.2g",
+            count,
+            (double)(delay)/(double)(G_USEC_PER_SEC));
 
     g_usleep (delay);
     if (delay < 30 * G_USEC_PER_SEC) {
@@ -290,7 +297,7 @@ get_artist_list (SjMetadataMusicbrainz5 *self,
     if (artist != NULL) {
       artist_credit->details = make_artist_details (self, artist);
     } else {
-      g_warning ("no Mb5Artist associated with Mb5NameCredit, falling back to Mb5NameCredit::name");
+      g_info ("no Mb5Artist associated with Mb5NameCredit, falling back to Mb5NameCredit::name");
       artist_credit->details = g_new0 (ArtistDetails, 1);
       GET (artist_credit->details->name, mb5_namecredit_get_name, name_credit);
     }
@@ -319,7 +326,7 @@ get_artist_info (GList *artists, char **name, char **sortname, char **id)
   }
 
   if (artist_count != 1) {
-      g_warning ("multiple artists");
+      g_info ("multiple artists");
       if (sortname != NULL)
         *sortname = NULL;
       if (id != NULL)


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