[evolution-data-server/evolution-data-server-3-12] Bug 678398 - Make evolution-source-registry debugging configurable
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] Bug 678398 - Make evolution-source-registry debugging configurable
- Date: Tue, 11 Nov 2014 17:43:04 +0000 (UTC)
commit 75a8369dd37a28468f462c5ed21ccf9ce790b1f2
Author: Milan Crha <mcrha redhat com>
Date: Tue Nov 11 18:42:45 2014 +0100
Bug 678398 - Make evolution-source-registry debugging configurable
addressbook/libedata-book/e-book-backend.c | 2 +-
calendar/libedata-cal/e-cal-backend.c | 2 +-
libebackend/e-authentication-session.c | 2 +-
libebackend/e-collection-backend.c | 2 +-
libebackend/e-dbus-server.c | 8 ++--
libebackend/e-server-side-source.c | 15 ++++--
libebackend/e-source-registry-server.c | 3 +-
libebackend/e-user-prompter-server.c | 2 +-
libedataserver/e-data-server-util.c | 49 ++++++++++++++++++++
libedataserver/e-data-server-util.h | 4 ++
modules/gnome-online-accounts/e-goa-client.c | 16 ++++--
.../e-signon-session-password.c | 2 +-
.../evolution-scan-gconf-tree-xml.c | 4 +-
.../evolution-source-registry-migrate-basedir.c | 10 ++--
...olution-source-registry-migrate-imap-to-imapx.c | 2 +-
.../evolution-source-registry-migrate-sources.c | 22 ++++----
.../evolution-source-registry.c | 2 +-
17 files changed, 105 insertions(+), 42 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index 7f070f4..137084c 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -681,7 +681,7 @@ book_backend_shutdown (EBookBackend *backend)
source = e_backend_get_source (E_BACKEND (backend));
- g_print (
+ e_source_registry_debug_print (
"The %s instance for \"%s\" is shutting down.\n",
G_OBJECT_TYPE_NAME (backend),
e_source_get_display_name (source));
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index c0a023a..d05bdc5 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -731,7 +731,7 @@ cal_backend_shutdown (ECalBackend *backend)
source = e_backend_get_source (E_BACKEND (backend));
- g_print (
+ e_source_registry_debug_print (
"The %s instance for \"%s\" is shutting down.\n",
G_OBJECT_TYPE_NAME (backend),
e_source_get_display_name (source));
diff --git a/libebackend/e-authentication-session.c b/libebackend/e-authentication-session.c
index 1b400d7..7c1a75a 100644
--- a/libebackend/e-authentication-session.c
+++ b/libebackend/e-authentication-session.c
@@ -134,7 +134,7 @@ authentication_session_msg (EAuthenticationSession *session,
g_string_append_vprintf (buffer, format, args);
va_end (args);
- g_print ("%s\n", buffer->str);
+ e_source_registry_debug_print ("%s\n", buffer->str);
g_string_free (buffer, TRUE);
}
diff --git a/libebackend/e-collection-backend.c b/libebackend/e-collection-backend.c
index bf1e3ff..4d30dd7 100644
--- a/libebackend/e-collection-backend.c
+++ b/libebackend/e-collection-backend.c
@@ -1180,7 +1180,7 @@ e_collection_backend_new_child (ECollectionBackend *backend,
collection_source = e_backend_get_source (E_BACKEND (backend));
- g_print (
+ e_source_registry_debug_print (
"%s: Pairing %s with resource %s\n",
e_source_get_display_name (collection_source),
e_source_get_uid (child_source), resource_id);
diff --git a/libebackend/e-dbus-server.c b/libebackend/e-dbus-server.c
index e2f58db..83bce3f 100644
--- a/libebackend/e-dbus-server.c
+++ b/libebackend/e-dbus-server.c
@@ -111,7 +111,7 @@ dbus_server_hang_up_cb (gpointer user_data)
{
EDBusServer *server = E_DBUS_SERVER (user_data);
- g_print ("Received hang up signal.\n");
+ e_source_registry_debug_print ("Received hang up signal.\n");
e_dbus_server_quit (server, E_DBUS_SERVER_EXIT_RELOAD);
return FALSE;
@@ -122,7 +122,7 @@ dbus_server_terminate_cb (gpointer user_data)
{
EDBusServer *server = E_DBUS_SERVER (user_data);
- g_print ("Received terminate signal.\n");
+ e_source_registry_debug_print ("Received terminate signal.\n");
e_dbus_server_quit (server, E_DBUS_SERVER_EXIT_NORMAL);
return FALSE;
@@ -187,7 +187,7 @@ dbus_server_bus_name_acquired (EDBusServer *server,
class = E_DBUS_SERVER_GET_CLASS (server);
g_return_if_fail (class->bus_name != NULL);
- g_print ("Bus name '%s' acquired.\n", class->bus_name);
+ e_source_registry_debug_print ("Bus name '%s' acquired.\n", class->bus_name);
}
static void
@@ -199,7 +199,7 @@ dbus_server_bus_name_lost (EDBusServer *server,
class = E_DBUS_SERVER_GET_CLASS (server);
g_return_if_fail (class->bus_name != NULL);
- g_print ("Bus name '%s' lost.\n", class->bus_name);
+ e_source_registry_debug_print ("Bus name '%s' lost.\n", class->bus_name);
e_dbus_server_quit (server, E_DBUS_SERVER_EXIT_NORMAL);
}
diff --git a/libebackend/e-server-side-source.c b/libebackend/e-server-side-source.c
index 90afc71..82b82e7 100644
--- a/libebackend/e-server-side-source.c
+++ b/libebackend/e-server-side-source.c
@@ -149,7 +149,10 @@ server_side_source_print_diff (ESource *source,
guint new_length = 0;
guint ii;
- g_print ("Saving %s\n", e_source_get_uid (source));
+ if (!e_source_registry_debug_enabled ())
+ return;
+
+ e_source_registry_debug_print ("Saving %s\n", e_source_get_uid (source));
if (old_data != NULL) {
old_strv = g_strsplit (old_data, "\n", 0);
@@ -163,18 +166,18 @@ server_side_source_print_diff (ESource *source,
for (ii = 0; ii < MIN (old_length, new_length); ii++) {
if (g_strcmp0 (old_strv[ii], new_strv[ii]) != 0) {
- g_print (" - : %s\n", old_strv[ii]);
- g_print (" + : %s\n", new_strv[ii]);
+ e_source_registry_debug_print (" - : %s\n", old_strv[ii]);
+ e_source_registry_debug_print (" + : %s\n", new_strv[ii]);
} else {
- g_print (" : %s\n", old_strv[ii]);
+ e_source_registry_debug_print (" : %s\n", old_strv[ii]);
}
}
for (; ii < old_length; ii++)
- g_print (" - : %s\n", old_strv[ii]);
+ e_source_registry_debug_print (" - : %s\n", old_strv[ii]);
for (; ii < new_length; ii++)
- g_print (" + : %s\n", new_strv[ii]);
+ e_source_registry_debug_print (" + : %s\n", new_strv[ii]);
g_strfreev (old_strv);
g_strfreev (new_strv);
diff --git a/libebackend/e-source-registry-server.c b/libebackend/e-source-registry-server.c
index 7525b8b..362c23f 100644
--- a/libebackend/e-source-registry-server.c
+++ b/libebackend/e-source-registry-server.c
@@ -1228,7 +1228,7 @@ source_registry_server_source_removed (ESourceRegistryServer *server,
object_path = g_dbus_object_get_object_path (dbus_object);
object_name = strrchr (object_path, '/') + 1;
- g_print ("Removing %s ('%s')\n", uid, object_name);
+ e_source_registry_debug_print ("Removing %s ('%s')\n", uid, object_name);
g_dbus_object_manager_server_unexport (
server->priv->object_manager, object_path);
@@ -2497,4 +2497,3 @@ e_source_registry_server_authenticate_finish (ESourceRegistryServer *server,
/* Assume success unless a GError is set. */
return !g_simple_async_result_propagate_error (simple, error);
}
-
diff --git a/libebackend/e-user-prompter-server.c b/libebackend/e-user-prompter-server.c
index 5348327..2884b9b 100644
--- a/libebackend/e-user-prompter-server.c
+++ b/libebackend/e-user-prompter-server.c
@@ -576,7 +576,7 @@ e_user_prompter_server_register (EUserPrompterServer *server,
return FALSE;
}
- g_print (
+ e_source_registry_debug_print (
"Registering %s for dialog '%s'\n",
G_OBJECT_TYPE_NAME (extension), dialog_name);
g_hash_table_insert (
diff --git a/libedataserver/e-data-server-util.c b/libedataserver/e-data-server-util.c
index 935d835..2a956fd 100644
--- a/libedataserver/e-data-server-util.c
+++ b/libedataserver/e-data-server-util.c
@@ -2255,3 +2255,52 @@ e_timeout_add_seconds_with_name (gint priority,
return tag;
}
+/**
+ * e_source_registry_debug_enabled:
+ *
+ * Returns: Whether debugging is enabled, that is,
+ * whether e_source_registry_debug_print() will produce any output.
+ *
+ * Since: 3.12.9
+ **/
+gboolean
+e_source_registry_debug_enabled (void)
+{
+ static gint esr_debug = -1;
+
+ if (esr_debug == -1)
+ esr_debug = g_strcmp0 (g_getenv ("ESR_DEBUG"), "1") == 0 ? 1 : 0;
+
+ return esr_debug == 1;
+}
+
+/**
+ * e_source_registry_debug_print:
+ * @format: a format string to print
+ * @...: other arguments for the format
+ *
+ * Prints the text only if a debugging is enabled with an environment
+ * variable ESR_DEBUG=1.
+ *
+ * Since: 3.12.9
+ **/
+void
+e_source_registry_debug_print (const gchar *format,
+ ...)
+{
+ GString *str;
+ va_list args;
+
+ if (!e_source_registry_debug_enabled ())
+ return;
+
+ str = g_string_new ("");
+
+ va_start (args, format);
+ g_string_vprintf (str, format, args);
+ va_end (args);
+
+ g_print ("%s", str->str);
+
+ g_string_free (str, TRUE);
+}
diff --git a/libedataserver/e-data-server-util.h b/libedataserver/e-data-server-util.h
index ab6c4f2..d496a96 100644
--- a/libedataserver/e-data-server-util.h
+++ b/libedataserver/e-data-server-util.h
@@ -212,6 +212,10 @@ void e_data_server_util_set_dbus_call_timeout
#endif /* EDS_DISABLE_DEPRECATED */
+gboolean e_source_registry_debug_enabled (void);
+void e_source_registry_debug_print (const gchar *format,
+ ...) G_GNUC_PRINTF (1, 2);
+
G_END_DECLS
#endif /* E_DATA_SERVER_UTIL_H */
diff --git a/modules/gnome-online-accounts/e-goa-client.c b/modules/gnome-online-accounts/e-goa-client.c
index a6cf7d5..8a99fb9 100644
--- a/modules/gnome-online-accounts/e-goa-client.c
+++ b/modules/gnome-online-accounts/e-goa-client.c
@@ -15,6 +15,12 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libedataserver/libedataserver.h>
+
#include "e-goa-client.h"
#define E_GOA_CLIENT_GET_PRIVATE(obj) \
@@ -76,7 +82,7 @@ e_goa_client_stash_orphan (EGoaClient *client,
goa_account_id = goa_account_get_id (goa_account);
g_return_if_fail (goa_account_id != NULL);
- g_print ("GOA: Stashing orphaned account '%s'\n", goa_account_id);
+ e_source_registry_debug_print ("GOA: Stashing orphaned account '%s'\n", goa_account_id);
g_mutex_lock (&client->priv->orphans_lock);
@@ -117,7 +123,7 @@ e_goa_client_claim_one_orphan (EGoaClient *client,
g_mutex_unlock (&client->priv->orphans_lock);
if (old_goa_object != NULL)
- g_print (
+ e_source_registry_debug_print (
"GOA: Claiming orphaned account '%s'\n",
goa_account_id);
@@ -138,7 +144,7 @@ e_goa_client_claim_all_orphans (EGoaClient *client)
g_mutex_unlock (&client->priv->orphans_lock);
if (list != NULL)
- g_print ("GOA: Claiming orphaned account(s)\n");
+ e_source_registry_debug_print ("GOA: Claiming orphaned account(s)\n");
return list;
}
@@ -217,9 +223,9 @@ e_goa_client_notify_name_owner_cb (GDBusObjectManager *manager,
G_DBUS_OBJECT_MANAGER_CLIENT (manager));
if (name_owner != NULL)
- g_print ("GOA: 'org.gnome.OnlineAccounts' name appeared\n");
+ e_source_registry_debug_print ("GOA: 'org.gnome.OnlineAccounts' name appeared\n");
else
- g_print ("GOA: 'org.gnome.OnlineAccounts' name vanished\n");
+ e_source_registry_debug_print ("GOA: 'org.gnome.OnlineAccounts' name vanished\n");
if (name_owner != NULL) {
GList *list, *link;
diff --git a/modules/ubuntu-online-accounts/e-signon-session-password.c
b/modules/ubuntu-online-accounts/e-signon-session-password.c
index 3475b02..1242676 100644
--- a/modules/ubuntu-online-accounts/e-signon-session-password.c
+++ b/modules/ubuntu-online-accounts/e-signon-session-password.c
@@ -95,7 +95,7 @@ signon_session_password_msg (EAuthenticationSession *session,
g_string_append_vprintf (buffer, format, args);
va_end (args);
- g_print ("%s\n", buffer->str);
+ e_source_registry_debug_print ("%s\n", buffer->str);
g_string_free (buffer, TRUE);
}
diff --git a/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c
b/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c
index 7664d24..27659cf 100644
--- a/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c
+++ b/services/evolution-source-registry/evolution-scan-gconf-tree-xml.c
@@ -22,6 +22,8 @@
#include <glib.h>
+#include <libedataserver/libedataserver.h>
+
#define PROGRAM_SUMMARY \
"Extracts Evolution accounts from a merged GConf tree file."
@@ -51,7 +53,7 @@ main (gint argc,
}
if (argc != 2) {
- g_print (
+ e_source_registry_debug_print (
"Usage: %s /path/to/%%gconf-tree.xml\n\n",
g_get_prgname ());
exit (0);
diff --git a/services/evolution-source-registry/evolution-source-registry-migrate-basedir.c
b/services/evolution-source-registry/evolution-source-registry-migrate-basedir.c
index f88767e..a26faaf 100644
--- a/services/evolution-source-registry/evolution-source-registry-migrate-basedir.c
+++ b/services/evolution-source-registry/evolution-source-registry-migrate-basedir.c
@@ -38,7 +38,7 @@ migrate_rename (const gchar *old_filename,
if (!old_filename_exists)
return TRUE;
- g_print (" mv %s %s\n", old_filename, new_filename);
+ e_source_registry_debug_print (" mv %s %s\n", old_filename, new_filename);
/* It's safe to go ahead and move directories because rename()
* will fail if the new directory already exists with content.
@@ -64,7 +64,7 @@ migrate_rmdir (const gchar *dirname)
gboolean success = TRUE;
if (g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
- g_print (" rmdir %s\n", dirname);
+ e_source_registry_debug_print (" rmdir %s\n", dirname);
if (g_rmdir (dirname) < 0) {
g_printerr (" FAILED: %s", g_strerror (errno));
if (errno == ENOTEMPTY) {
@@ -82,7 +82,7 @@ migrate_rmdir (const gchar *dirname)
/* Align the filenames beneath the error message. */
while ((basename = g_dir_read_name (dir)) != NULL)
- g_print (" %s\n", basename);
+ e_source_registry_debug_print (" %s\n", basename);
g_dir_close (dir);
}
@@ -281,7 +281,7 @@ migrate_to_user_cache_dir (const gchar *old_base_dir)
old_cache_dir = g_build_filename (old_base_dir, "cache", NULL);
new_cache_dir = e_get_user_cache_dir ();
- g_print ("Migrating cached backend data\n");
+ e_source_registry_debug_print ("Migrating cached backend data\n");
/* We don't want to move the source directory directly because the
* destination directory may already exist with content. Instead
@@ -354,7 +354,7 @@ migrate_to_user_data_dir (const gchar *old_base_dir)
new_data_dir = e_get_user_data_dir ();
- g_print ("Migrating local backend data\n");
+ e_source_registry_debug_print ("Migrating local backend data\n");
/* We don't want to move the source directory directly because the
* destination directory may already exist with content. Instead
diff --git a/services/evolution-source-registry/evolution-source-registry-migrate-imap-to-imapx.c
b/services/evolution-source-registry/evolution-source-registry-migrate-imap-to-imapx.c
index a2e0e3d..a0ce795 100644
--- a/services/evolution-source-registry/evolution-source-registry-migrate-imap-to-imapx.c
+++ b/services/evolution-source-registry/evolution-source-registry-migrate-imap-to-imapx.c
@@ -70,7 +70,7 @@ evolution_source_registry_migrate_imap_to_imapx (ESourceRegistryServer *server,
if (!backend_is_imap)
return FALSE;
- g_print ("Converting %s from IMAP to IMAPX\n", uid);
+ e_source_registry_debug_print ("Converting %s from IMAP to IMAPX\n", uid);
g_key_file_set_string (key_file, group_name, "BackendName", "imapx");
diff --git a/services/evolution-source-registry/evolution-source-registry-migrate-sources.c
b/services/evolution-source-registry/evolution-source-registry-migrate-sources.c
index f9cf7ae..ff41e95 100644
--- a/services/evolution-source-registry/evolution-source-registry-migrate-sources.c
+++ b/services/evolution-source-registry/evolution-source-registry-migrate-sources.c
@@ -353,9 +353,9 @@ migrate_parse_commit_changes (ParseType parse_type,
if (uid == NULL)
return FALSE;
- g_print (" * Source: %s\n", uid);
+ e_source_registry_debug_print (" * Source: %s\n", uid);
- g_print (" Writing key file...\n");
+ e_source_registry_debug_print (" Writing key file...\n");
/* Save the key file contents to disk. */
contents = g_key_file_to_data (key_file, &length, NULL);
@@ -400,21 +400,21 @@ migrate_parse_commit_changes (ParseType parse_type,
old_directory_exists = g_file_test (old_directory, G_FILE_TEST_EXISTS);
new_directory_exists = g_file_test (new_directory, G_FILE_TEST_EXISTS);
- g_print (
+ e_source_registry_debug_print (
" Checking for old cache dir '%s'... %s\n",
old_directory,
old_directory_exists ? "found" : "not found");
if (old_directory_exists) {
- g_print (
+ e_source_registry_debug_print (
" Checking for new cache dir '%s'... %s\n",
new_directory,
new_directory_exists ? "found" : "not found");
if (new_directory_exists)
- g_print (" Skipping cache directory rename.\n");
+ e_source_registry_debug_print (" Skipping cache directory rename.\n");
else {
- g_print (" Renaming old cache directory...\n");
+ e_source_registry_debug_print (" Renaming old cache directory...\n");
if (g_rename (old_directory, new_directory) < 0) {
g_set_error (
error, G_FILE_ERROR,
@@ -444,21 +444,21 @@ migrate_parse_commit_changes (ParseType parse_type,
old_directory_exists = g_file_test (old_directory, G_FILE_TEST_EXISTS);
new_directory_exists = g_file_test (new_directory, G_FILE_TEST_EXISTS);
- g_print (
+ e_source_registry_debug_print (
" Checking for old data dir '%s'... %s\n",
old_directory,
old_directory_exists ? "found" : "not found");
if (old_directory_exists) {
- g_print (
+ e_source_registry_debug_print (
" Checking for new data dir '%s'... %s\n",
new_directory,
new_directory_exists ? "found" : "not found");
if (new_directory_exists)
- g_print (" Skipping data directory rename.\n");
+ e_source_registry_debug_print (" Skipping data directory rename.\n");
else {
- g_print (" Renaming old data directory...\n");
+ e_source_registry_debug_print (" Renaming old data directory...\n");
if (g_rename (old_directory, new_directory) < 0) {
g_set_error (
error, G_FILE_ERROR,
@@ -3678,7 +3678,7 @@ migrate_and_remove_key (const gchar *filename,
filename, &contents, &length, &local_error);
if (contents != NULL) {
- g_print ("Migrating %s from GConf...\n", migrate_type_name);
+ e_source_registry_debug_print ("Migrating %s from GConf...\n", migrate_type_name);
migrate_parse_gconf_xml (
parse_type, contents, length, &local_error);
diff --git a/services/evolution-source-registry/evolution-source-registry.c
b/services/evolution-source-registry/evolution-source-registry.c
index b258c81..51965d3 100644
--- a/services/evolution-source-registry/evolution-source-registry.c
+++ b/services/evolution-source-registry/evolution-source-registry.c
@@ -216,7 +216,7 @@ reload:
const gchar *config_dir;
gchar *dirname;
- g_print ("Reloading...\n");
+ e_source_registry_debug_print ("Reloading...\n");
/* It's possible the Reload is called after restore, where
* the ~/.config/evolution/sources directory can be missing,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]