From a4ad0e220519d608c8e809e773efee5450654d3a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 19 Jul 2011 01:07:53 +0200 Subject: [PATCH 2/2] Add debug logs to TplLogStoreTracker --- telepathy-logger/debug-internal.h | 3 ++- telepathy-logger/debug.c | 1 + telepathy-logger/log-store-tracker.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletions(-) diff --git a/telepathy-logger/debug-internal.h b/telepathy-logger/debug-internal.h index 1ea214a..fb40a26 100644 --- a/telepathy-logger/debug-internal.h +++ b/telepathy-logger/debug-internal.h @@ -44,7 +44,8 @@ typedef enum TPL_DEBUG_LOG_STORE = 1 << 7, TPL_DEBUG_MAIN = 1 << 8, TPL_DEBUG_OBSERVER = 1 << 9, - TPL_DEBUG_TESTSUITE = 1 << 10 + TPL_DEBUG_TESTSUITE = 1 << 10, + TPL_DEBUG_TRACKER = 1 << 11 } TplDebugFlags; void _tpl_debug_set_flags_from_env (void); diff --git a/telepathy-logger/debug.c b/telepathy-logger/debug.c index 421cd77..5787d46 100644 --- a/telepathy-logger/debug.c +++ b/telepathy-logger/debug.c @@ -39,6 +39,7 @@ static GDebugKey keys[] = { { "main", TPL_DEBUG_MAIN }, { "observer", TPL_DEBUG_OBSERVER }, { "testsuite", TPL_DEBUG_TESTSUITE }, + { "tracker", TPL_DEBUG_TRACKER }, { 0, }, }; diff --git a/telepathy-logger/log-store-tracker.c b/telepathy-logger/log-store-tracker.c index c7ca5d9..deada58 100644 --- a/telepathy-logger/log-store-tracker.c +++ b/telepathy-logger/log-store-tracker.c @@ -32,6 +32,9 @@ #include "telepathy-logger/log-manager-internal.h" #include "telepathy-logger/util-internal.h" +#define DEBUG_FLAG TPL_DEBUG_TRACKER +#include "telepathy-logger/debug-internal.h" + #define TPL_LOG_STORE_TRACKER_GRAPH_URN "urn:uuid:287cf12d-debb-cd35-64e3-c4bf36a9246d" #define TPL_LOG_STORE_ACCOUNT_URN_PREFIX "urn:telepathy-account:" #define TPL_LOG_STORE_CONTACT_URN_PREFIX "urn:telepathy-contact:" @@ -362,6 +365,8 @@ init_sparql_flush (TplLogStoreTracker *self) return FALSE; flush_n_items = MIN (array->len, 100); + DEBUG ("Flushing %d updates, %d remaining", + flush_n_items, array->len - flush_n_items); tracker_sparql_connection_update_array_async (connection, (gchar **) array->pdata, @@ -392,6 +397,8 @@ process_account (TplLogStoreTracker *self, tracker_sparql_builder_predicate (builder, "a"); tracker_sparql_builder_object (builder, "nco:IMAccount"); + DEBUG ("Storing account: '%s'", subject); + /* Account address */ tracker_sparql_builder_predicate (builder, "nco:imAccountAddress"); @@ -445,6 +452,8 @@ process_contact (TplLogStoreTracker *self, subject = tracker_sparql_escape_uri_printf (TPL_LOG_STORE_CONTACT_URN_PREFIX "%s", tp_contact_get_identifier (contact)); + + DEBUG ("Storing contact: '%s'", subject); tracker_sparql_builder_subject_iri (builder, subject); g_free (subject); @@ -525,6 +534,8 @@ process_communication_channel (TplLogStoreTracker *self, else return FALSE; + DEBUG ("Storing communication channel: '%s'", subject); + builder = tracker_sparql_builder_new_update (); tracker_sparql_builder_insert_open (builder, TPL_LOG_STORE_TRACKER_GRAPH_URN); @@ -608,6 +619,10 @@ process_event (TplLogStoreTracker *self, receiver = tpl_event_get_receiver (event); timestamp = tpl_event_get_timestamp (event); + DEBUG ("Storing event: '%s -> %s'", + tpl_entity_get_identifier (sender), + tpl_entity_get_identifier (receiver)); + builder = tracker_sparql_builder_new_update (); tracker_sparql_builder_insert_open (builder, TPL_LOG_STORE_TRACKER_GRAPH_URN); @@ -1277,6 +1292,7 @@ log_store_tracker_clear (TplLogStore *store) TplLogStoreTracker *self; gchar *sparql; + DEBUG ("Clearing all Tracker information"); self = TPL_LOG_STORE_TRACKER (store); sparql = g_strdup ("DELETE {" " GRAPH <" TPL_LOG_STORE_TRACKER_GRAPH_URN "> {" @@ -1302,6 +1318,9 @@ log_store_tracker_clear_account (TplLogStore *store, self = TPL_LOG_STORE_TRACKER (store); subject = tracker_sparql_escape_uri_printf (TPL_LOG_STORE_ACCOUNT_URN_PREFIX "%s", tp_account_get_normalized_name (account)); + + DEBUG ("Clearing account: '%s'", subject); + /* Delete every message with * all contacts in the account */ @@ -1398,6 +1417,8 @@ log_store_tracker_clear_entity (TplLogStore *store, else return; + DEBUG ("Clearing communication channel: '%s'", subject); + /* Delete every message with the given entity */ sparql = g_strdup_printf ("DELETE {" " GRAPH <" TPL_LOG_STORE_TRACKER_GRAPH_URN "> {" -- 1.7.6