[gnome-photos/wip/rishi/query: 4/8] tracker-queue: Log each Query's source and tag fields
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/query: 4/8] tracker-queue: Log each Query's source and tag fields
- Date: Mon, 18 Sep 2017 12:58:27 +0000 (UTC)
commit 2e079ff8693c290f9a0f252d45ba8bc9637400a4
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Sep 4 17:15:44 2017 +0200
tracker-queue: Log each Query's source and tag fields
This enables more human-readable logging of the Tracker queries by
annotating the SPARQL strings with a human-readable tag; and a
description of the current Source, if any.
https://bugzilla.gnome.org/show_bug.cgi?id=787833
src/photos-tracker-queue.c | 49 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/src/photos-tracker-queue.c b/src/photos-tracker-queue.c
index 4043f49..ea4b2a9 100644
--- a/src/photos-tracker-queue.c
+++ b/src/photos-tracker-queue.c
@@ -29,6 +29,8 @@
#include <tracker-sparql.h>
#include "photos-debug.h"
+#include "photos-filterable.h"
+#include "photos-source.h"
#include "photos-tracker-queue.h"
@@ -63,8 +65,10 @@ struct _PhotosTrackerQueueData
GAsyncReadyCallback callback;
GCancellable *cancellable;
GDestroyNotify destroy_data;
+ PhotosSource *source;
PhotosTrackerQueryType query_type;
gchar *sparql;
+ gchar *tag;
gpointer user_data;
};
@@ -79,7 +83,9 @@ static void
photos_tracker_queue_data_free (PhotosTrackerQueueData *data)
{
g_clear_object (&data->cancellable);
+ g_clear_object (&data->source);
g_free (data->sparql);
+ g_free (data->tag);
if (data->destroy_data != NULL)
(*data->destroy_data) (data->user_data);
@@ -89,7 +95,9 @@ photos_tracker_queue_data_free (PhotosTrackerQueueData *data)
static PhotosTrackerQueueData *
-photos_tracker_queue_data_new (const gchar *sparql,
+photos_tracker_queue_data_new (PhotosSource *source,
+ const gchar *sparql,
+ const gchar *tag,
PhotosTrackerQueryType query_type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -99,7 +107,12 @@ photos_tracker_queue_data_new (const gchar *sparql,
PhotosTrackerQueueData *data;
data = g_slice_new0 (PhotosTrackerQueueData);
+
+ if (source != NULL)
+ data->source = g_object_ref (source);
+
data->sparql = g_strdup (sparql);
+ data->tag = g_strdup (tag);
data->query_type = query_type;
data->cancellable = cancellable;
data->callback = callback;
@@ -111,6 +124,26 @@ photos_tracker_queue_data_new (const gchar *sparql,
static void
+photos_tracker_queue_log_query (PhotosTrackerQueueData *data)
+{
+ if (data->tag != NULL && data->tag[0] != '\0')
+ photos_debug (PHOTOS_DEBUG_TRACKER, "%s", data->tag);
+
+ if (data->source != NULL)
+ {
+ const gchar *id;
+ const gchar *name;
+
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (data->source));
+ name = photos_source_get_name (data->source);
+ photos_debug (PHOTOS_DEBUG_TRACKER, "Source (%s): %s", id, name);
+ }
+
+ photos_debug (PHOTOS_DEBUG_TRACKER, "%s", data->sparql);
+}
+
+
+static void
photos_tracker_queue_collector (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
PhotosTrackerQueue *self = PHOTOS_TRACKER_QUEUE (user_data);
@@ -141,7 +174,7 @@ photos_tracker_queue_check (PhotosTrackerQueue *self)
data = g_queue_peek_head (self->queue);
self->running = TRUE;
- photos_debug (PHOTOS_DEBUG_TRACKER, "%s", data->sparql);
+ photos_tracker_queue_log_query (data);
switch (data->query_type)
{
@@ -306,7 +339,9 @@ photos_tracker_queue_select (PhotosTrackerQueue *self,
if (cancellable != NULL)
g_object_ref (cancellable);
- data = photos_tracker_queue_data_new (query->sparql,
+ data = photos_tracker_queue_data_new (query->source,
+ query->sparql,
+ query->tag,
PHOTOS_TRACKER_QUERY_SELECT,
cancellable,
callback,
@@ -331,7 +366,9 @@ photos_tracker_queue_update (PhotosTrackerQueue *self,
if (cancellable != NULL)
g_object_ref (cancellable);
- data = photos_tracker_queue_data_new (query->sparql,
+ data = photos_tracker_queue_data_new (query->source,
+ query->sparql,
+ query->tag,
PHOTOS_TRACKER_QUERY_UPDATE,
cancellable,
callback,
@@ -356,7 +393,9 @@ photos_tracker_queue_update_blank (PhotosTrackerQueue *self,
if (cancellable != NULL)
g_object_ref (cancellable);
- data = photos_tracker_queue_data_new (query->sparql,
+ data = photos_tracker_queue_data_new (query->source,
+ query->sparql,
+ query->tag,
PHOTOS_TRACKER_QUERY_UPDATE_BLANK,
cancellable,
callback,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]