[tracker] libtracker-miner: Give up on detailed decorator error logging



commit b9b776f3303dd0d749df8b8653bae504718a5ef4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 8 18:24:04 2016 +0200

    libtracker-miner: Give up on detailed decorator error logging
    
    It was the hope that this error logging would lead to useful
    but reports that helped qualitatively improve the extractor
    modules soon enough.
    
    But people suck, and instead we got lots of bugs about how
    much we spam syslog (as if we used the "warning" logging level
    just because) or how we violated their privacy, without further
    thinking that there might be reasons for those warnings in the
    first place (i.e. bugs that need fixing). Those bug reports
    are usually plagued with half-cut,half-edited snippets from
    syslog to prove their point, while at the same time invalidating
    their usefulness.
    
    So, change of approach. Now we just include the URN/URI in the
    error warning, and point people to using TRACKER_VERBOSITY=3 in
    order to get more information. The debug information will contain
    the full unedited sparql, and the relevant info will be surrounded
    by dotted lines so it is made clear the information that is useful.
    
    This will require an extra step for the people trying to be helpful,
    which hopefully those are willing to take. It will also hopefully
    calm the bunch of complains, and will give me no hesitation to close
    any further one we get as invalid.

 src/libtracker-miner/tracker-decorator.c |   67 ++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 17 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-decorator.c b/src/libtracker-miner/tracker-decorator.c
index c874f21..8f161d0 100644
--- a/src/libtracker-miner/tracker-decorator.c
+++ b/src/libtracker-miner/tracker-decorator.c
@@ -290,6 +290,52 @@ decorator_update_state (TrackerDecorator *decorator,
 }
 
 static void
+item_warn (TrackerSparqlConnection *conn,
+           gint                     id,
+           const gchar             *sparql,
+           const GError            *error)
+{
+       TrackerSparqlCursor *cursor;
+       const gchar *elem;
+       gchar *query;
+
+       query = g_strdup_printf ("SELECT COALESCE (nie:url (?u), ?u) {"
+                                "  ?u a rdfs:Resource. "
+                                "  FILTER (tracker:id (?u) = %d)"
+                                "}", id);
+
+       cursor = tracker_sparql_connection_query (conn, query, NULL, NULL);
+       g_free (query);
+
+       g_debug ("--8<------------------------------");
+       g_debug ("The information relevant for a bug report is between "
+                "the dotted lines");
+
+       if (cursor &&
+           tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+               elem = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+               g_warning ("Could not insert metadata for item \"%s\": %s",
+                          elem, error->message);
+       } else {
+               g_warning ("Could not insert metadata for item with ID %d: %s",
+                          id, error->message);
+       }
+
+       g_warning ("If the error above is recurrent for the same item/ID, "
+                  "consider running \"%s\" in the terminal with the "
+                  "TRACKER_VERBOSITY=3 environment variable, and filing a "
+                  "bug with the additional information", g_get_prgname ());
+
+       g_debug ("Sparql was:\n%s", sparql);
+       g_debug ("NOTE: The information above may contain data you "
+                "consider sensitive. Feel free to edit it out, but please "
+                "keep it as unmodified as you possibly can.");
+       g_debug ("------------------------------>8--");
+
+       g_clear_object (&cursor);
+}
+
+static void
 decorator_commit_cb (GObject      *object,
                      GAsyncResult *result,
                      gpointer      user_data)
@@ -318,24 +364,11 @@ decorator_commit_cb (GObject      *object,
                        child_error = g_ptr_array_index (errors, i);
                        update = &g_array_index (priv->commit_buffer, SparqlUpdate, i);
 
-                       if (child_error) {
-                               gchar *msg, *p;
+                       if (!child_error)
+                               continue;
 
-                               decorator_blacklist_add (decorator, update->id);
-
-                               msg = g_strdup (update->sparql);
-                               p = strstr (msg, "nie:plainTextContent");
-
-                               if (p != NULL)
-                                       *p = '\0';
-
-                               g_warning ("Task %d, error: %s\n"
-                                          "Sparql was:\n%s\n",
-                                          i, child_error->message,
-                                          msg);
-
-                               g_free (msg);
-                       }
+                       decorator_blacklist_add (decorator, update->id);
+                       item_warn (conn, update->id, update->sparql, child_error);
                }
 
                g_ptr_array_unref (errors);


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