[frogr] Allow configuring debug mode from configure script
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Allow configuring debug mode from configure script
- Date: Sat, 22 Jan 2011 01:47:29 +0000 (UTC)
commit 984021512b49056663decd5693d70eed3808dd40
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Sat Jan 22 02:45:32 2011 +0100
Allow configuring debug mode from configure script
Passing --enable-debug will automatically set the -g3 -O0 flags to be
used with gcc and will enable output through the DEBUG (...) macro.
configure.ac | 16 ++++++++++++++-
src/flicksoup/fsp-session.c | 17 +++++++++++----
src/frogr-add-tags-dialog.c | 3 +-
src/frogr-config.c | 7 +++--
src/frogr-controller.c | 46 +++++++++++++++++++++---------------------
src/frogr-global-defs.h | 6 +++++
src/frogr-main-view.c | 10 ++++----
src/frogr-picture-loader.c | 3 +-
src/frogr-settings-dialog.c | 23 +++++++++++----------
src/frogr-util.c | 2 +-
src/main.c | 2 +-
11 files changed, 83 insertions(+), 52 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 54bba12..cc818fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,6 +81,19 @@ GETTEXT_PACKAGE=frogr
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package])
+# Debug mode
+AC_MSG_CHECKING([Checking whether to enable debug output])
+AC_ARG_ENABLE(debug,
+ AC_HELP_STRING([--enable-debug],
+ [turn on debugging [default=no]]),
+ [],[enable_debug="no"])
+AC_MSG_RESULT([$enable_debug])
+
+if test "$enable_debug" = "yes"; then
+ AC_DEFINE([DEBUG_ENABLED], [1], [Debug enabled])
+ CFLAGS="$CFLAGS -g3 -O0"
+fi
+
# Produce output files
AC_CONFIG_FILES([
@@ -98,7 +111,8 @@ echo "*************************************"
echo "*** frogr is ready to be compiled ***"
echo "*************************************"
echo ""
-echo "Using GTK+ version: $with_gtk"
+echo "Using GTK+ version : $with_gtk"
+echo "Enable debug : $enable_debug"
echo ""
echo ""
echo "Configure successful. Type 'make' to compile"
diff --git a/src/flicksoup/fsp-session.c b/src/flicksoup/fsp-session.c
index 2f1806e..46294bc 100644
--- a/src/flicksoup/fsp-session.c
+++ b/src/flicksoup/fsp-session.c
@@ -30,6 +30,7 @@
#include "fsp-parser.h"
#include "fsp-session.h"
+#include <config.h>
#include <libsoup/soup.h>
#include <stdarg.h>
#include <string.h>
@@ -37,6 +38,12 @@
#define FLICKR_API_BASE_URL "http://api.flickr.com/services/rest"
#define FLICKR_API_UPLOAD_URL "http://api.flickr.com/services/upload"
+#ifdef DEBUG_ENABLED
+#define DEBUG(...) g_debug (__VA_ARGS__);
+#else
+#define DEBUG(...)
+#endif
+
#define FSP_SESSION_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
FSP_TYPE_SESSION, \
@@ -602,7 +609,7 @@ _load_file_contents_cb (GObject *object,
soup_session_queue_message (soup_session, msg,
_photo_upload_soup_session_cb, ard_clos);
- g_debug ("\nRequested URL:\n%s\n", FLICKR_API_UPLOAD_URL);
+ DEBUG ("\nRequested URL:\n%s\n", FLICKR_API_UPLOAD_URL);
/* Free */
g_hash_table_unref (extra_params);
@@ -670,7 +677,7 @@ _get_params_table_from_valist (const gchar *first_param,
if (v != NULL)
g_hash_table_insert (table, g_strdup (p), g_strdup (v));
else
- g_debug ("Missing value for %s. Ignoring parameter.", p);
+ DEBUG ("Missing value for %s. Ignoring parameter.", p);
}
return table;
@@ -974,7 +981,7 @@ _perform_async_request (SoupSession *soup_session,
/* Queue the message */
soup_session_queue_message (soup_session, msg, request_cb, clos);
- g_debug ("\nRequested URL:\n%s\n", url);
+ DEBUG ("\nRequested URL:\n%s\n", url);
}
void
@@ -995,7 +1002,7 @@ _soup_session_cancelled_cb (GCancellable *cancellable,
soup_session_cancel_message (session, message, SOUP_STATUS_CANCELLED);
- g_debug ("%s", "Remote request cancelled!");
+ DEBUG ("%s", "Remote request cancelled!");
}
void
@@ -1023,7 +1030,7 @@ _handle_soup_response (SoupMessage *msg,
response_str = g_strndup (msg->response_body->data, msg->response_body->length);
response_len = (ulong) msg->response_body->length;
if (response_str)
- g_debug ("\nResponse got:\n%s\n", response_str);
+ DEBUG ("\nResponse got:\n%s\n", response_str);
/* Get value from response */
if (!_check_errors_on_soup_response (msg, &err))
diff --git a/src/frogr-add-tags-dialog.c b/src/frogr-add-tags-dialog.c
index a718210..f04d9a6 100644
--- a/src/frogr-add-tags-dialog.c
+++ b/src/frogr-add-tags-dialog.c
@@ -22,6 +22,7 @@
#include "frogr-add-tags-dialog.h"
+#include "frogr-global-defs.h"
#include "frogr-picture.h"
#include <config.h>
@@ -201,7 +202,7 @@ _dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
GSList *item;
guint n_pictures;
- g_debug ("Adding tags to picture(s): %s", tags);
+ DEBUG ("Adding tags to picture(s): %s", tags);
/* Iterate over the rest of elements */
n_pictures = g_slist_length (priv->pictures);
diff --git a/src/frogr-config.c b/src/frogr-config.c
index cc69cc7..6000b75 100644
--- a/src/frogr-config.c
+++ b/src/frogr-config.c
@@ -24,6 +24,7 @@
#include "frogr-config.h"
#include "frogr-account.h"
+#include "frogr-global-defs.h"
#include <glib/gstdio.h>
#include <libxml/parser.h>
@@ -139,7 +140,7 @@ _load_settings (FrogrConfig *self, const gchar *config_dir)
if (xml)
node = xmlDocGetRootElement (xml);
else
- g_debug ("Could not load '%s/%s'", config_dir, SETTINGS_FILENAME);
+ DEBUG ("Could not load '%s/%s'", config_dir, SETTINGS_FILENAME);
if (node && node->name && !xmlStrcmp (node->name, (const xmlChar*) "settings"))
{
@@ -368,7 +369,7 @@ _load_accounts (FrogrConfig *self, const gchar *config_dir)
if (xml)
node = xmlDocGetRootElement (xml);
else
- g_debug ("Could not load '%s/%s'", config_dir, ACCOUNTS_FILENAME);
+ DEBUG ("Could not load '%s/%s'", config_dir, ACCOUNTS_FILENAME);
if (node && node->name && !xmlStrcmp (node->name, (const xmlChar*) "accounts"))
{
@@ -811,7 +812,7 @@ frogr_config_add_account (FrogrConfig *self,
if (found_account)
{
frogr_config_remove_account (self, account_id);
- g_debug ("Account of ID %s already in the configuration system", account_id);
+ DEBUG ("Account of ID %s already in the configuration system", account_id);
}
priv->accounts = g_slist_append (priv->accounts, g_object_ref (faccount));
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index fc85bf6..3b0555b 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -338,7 +338,7 @@ _notify_error_to_user (FrogrController *self, GError *error)
error_function (window, msg);
}
- g_debug ("%s", msg);
+ DEBUG ("%s", msg);
g_free (msg);
}
@@ -379,7 +379,7 @@ _auth_failed_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data
if (response == GTK_RESPONSE_OK)
{
frogr_controller_show_auth_dialog (frogr_controller_get_instance ());
- g_debug ("%s", "Showing the authorization dialog once again...");
+ DEBUG ("%s", "Showing the authorization dialog once again...");
}
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -397,12 +397,12 @@ _get_auth_url_cb (GObject *obj, GAsyncResult *res, gpointer data)
if (error != NULL)
{
_notify_error_to_user (self, error);
- g_debug ("Error getting auth URL: %s", error->message);
+ DEBUG ("Error getting auth URL: %s", error->message);
g_error_free (error);
return;
}
- g_debug ("Auth URL: %s", auth_url ? auth_url : "No URL got");
+ DEBUG ("Auth URL: %s", auth_url ? auth_url : "No URL got");
/* Open url in the default application */
if (auth_url != NULL)
@@ -447,7 +447,7 @@ _complete_auth_cb (GObject *object, GAsyncResult *result, gpointer data)
frogr_controller_set_active_account (controller, account);
- g_debug ("%s", "Authorization successfully completed!");
+ DEBUG ("%s", "Authorization successfully completed!");
}
fsp_data_free (FSP_DATA (auth_token));
@@ -456,7 +456,7 @@ _complete_auth_cb (GObject *object, GAsyncResult *result, gpointer data)
if (error != NULL)
{
_notify_error_to_user (controller, error);
- g_debug ("Authorization failed: %s", error->message);
+ DEBUG ("Authorization failed: %s", error->message);
g_error_free (error);
}
}
@@ -665,7 +665,7 @@ _create_photoset_cb (GObject *object, GAsyncResult *res, gpointer data)
{
/* We plainly ignore errors in this stage, as we don't want
them to interrupt the global upload process */
- g_debug ("Error creating set: %s", error->message);
+ DEBUG ("Error creating set: %s", error->message);
g_error_free (error);
up_st->error = NULL;
}
@@ -707,7 +707,7 @@ _add_to_photoset_cb (GObject *object, GAsyncResult *res, gpointer data)
{
/* We plainly ignore errors in this stage, as we don't want
them to interrupt the global upload process */
- g_debug ("Error adding picture to set: %s", error->message);
+ DEBUG ("Error adding picture to set: %s", error->message);
g_error_free (error);
up_st->error = NULL;
}
@@ -765,7 +765,7 @@ _add_to_group_cb (GObject *object, GAsyncResult *res, gpointer data)
{
/* We plainly ignore errors in this stage, as we don't want
them to interrupt the global upload process */
- g_debug ("Error adding picture to group: %s", error->message);
+ DEBUG ("Error adding picture to group: %s", error->message);
g_error_free (error);
up_st->error = NULL;
}
@@ -879,7 +879,7 @@ _notify_creating_set (FrogrController *self,
progress_text = g_strdup_printf ("Creating new photoset for picture %s. "
"Title: %s / Description: %s",
picture_title, set_title, set_desc);
- g_debug ("%s", progress_text);
+ DEBUG ("%s", progress_text);
g_free (progress_text);
}
@@ -901,7 +901,7 @@ _notify_adding_to_set (FrogrController *self,
set_title = frogr_photoset_get_title (set);
progress_text = g_strdup_printf ("Adding picture %s to photoset %sâ?¦",
picture_title, set_title);
- g_debug ("%s", progress_text);
+ DEBUG ("%s", progress_text);
g_free (progress_text);
}
@@ -923,7 +923,7 @@ _notify_adding_to_group (FrogrController *self,
group_name = frogr_group_get_name (group);
progress_text = g_strdup_printf ("Adding picture %s to group %sâ?¦",
picture_title, group_name);
- g_debug ("%s", progress_text);
+ DEBUG ("%s", progress_text);
g_free (progress_text);
}
@@ -981,12 +981,12 @@ _on_pictures_uploaded (FrogrController *self,
_fetch_sets (self);
_fetch_tags (self);
- g_debug ("%s", "Success uploading pictures!");
+ DEBUG ("%s", "Success uploading pictures!");
}
else
{
_notify_error_to_user (self, error);
- g_debug ("Error uploading pictures: %s", error->message);
+ DEBUG ("Error uploading pictures: %s", error->message);
g_error_free (error);
}
@@ -1043,7 +1043,7 @@ _fetch_sets_cb (GObject *object, GAsyncResult *res, gpointer data)
data_sets_list = fsp_session_get_photosets_finish (session, res, &error);
if (error != NULL)
{
- g_debug ("Fetching list of sets: %s (%d)", error->message, error->code);
+ DEBUG ("Fetching list of sets: %s (%d)", error->message, error->code);
if (error->code == FSP_ERROR_NOT_AUTHENTICATED)
frogr_controller_revoke_authorization (controller);
@@ -1124,7 +1124,7 @@ _fetch_groups_cb (GObject *object, GAsyncResult *res, gpointer data)
data_groups_list = fsp_session_get_groups_finish (session, res, &error);
if (error != NULL)
{
- g_debug ("Fetching list of groups: %s (%d)", error->message, error->code);
+ DEBUG ("Fetching list of groups: %s (%d)", error->message, error->code);
if (error->code == FSP_ERROR_NOT_AUTHENTICATED)
frogr_controller_revoke_authorization (controller);
@@ -1200,7 +1200,7 @@ _fetch_account_info_cb (GObject *object, GAsyncResult *res, gpointer data)
auth_token = fsp_session_check_auth_info_finish (session, res, &error);
if (error != NULL)
{
- g_debug ("Fetching basic info from the account: %s", error->message);
+ DEBUG ("Fetching basic info from the account: %s", error->message);
if (error->code == FSP_ERROR_NOT_AUTHENTICATED)
frogr_controller_revoke_authorization (controller);
@@ -1270,7 +1270,7 @@ _fetch_account_extra_info_cb (GObject *object, GAsyncResult *res, gpointer data)
upload_status = fsp_session_get_upload_status_finish (session, res, &error);
if (error != NULL)
{
- g_debug ("Fetching extra info from the account: %s", error->message);
+ DEBUG ("Fetching extra info from the account: %s", error->message);
if (error->code == FSP_ERROR_NOT_AUTHENTICATED)
frogr_controller_revoke_authorization (controller);
@@ -1346,7 +1346,7 @@ _fetch_tags_cb (GObject *object, GAsyncResult *res, gpointer data)
tags_list = fsp_session_get_tags_list_finish (session, res, &error);
if (error != NULL)
{
- g_debug ("Fetching list of tags: %s", error->message);
+ DEBUG ("Fetching list of tags: %s", error->message);
if (error->code == FSP_ERROR_NOT_AUTHENTICATED)
frogr_controller_revoke_authorization (controller);
@@ -1739,7 +1739,7 @@ frogr_controller_run_app (FrogrController *self)
if (priv->app_running)
{
- g_debug ("%s", "Application already running");
+ DEBUG ("%s", "Application already running");
return FALSE;
}
@@ -1760,7 +1760,7 @@ frogr_controller_run_app (FrogrController *self)
gtk_main ();
/* Application shutting down from this point on */
- g_debug ("%s", "Shutting down application...");
+ DEBUG ("%s", "Shutting down application...");
return TRUE;
}
@@ -1887,7 +1887,7 @@ frogr_controller_set_proxy (FrogrController *self,
/* The host is mandatory to set up a proxy */
if (host == NULL || *host == '\0') {
fsp_session_set_http_proxy (priv->session, NULL, NULL, NULL, NULL);
- g_debug ("%s", "Not using HTTP proxy");
+ DEBUG ("%s", "Not using HTTP proxy");
} else {
gboolean has_port = FALSE;
gboolean has_username = FALSE;
@@ -1901,7 +1901,7 @@ frogr_controller_set_proxy (FrogrController *self,
if (has_username && has_password)
auth_part = g_strdup_printf ("%s:%s@", username, password);
- g_debug ("Using HTTP proxy: %s%s:%s", auth_part ? auth_part : "", host, port);
+ DEBUG ("Using HTTP proxy: %s%s:%s", auth_part ? auth_part : "", host, port);
g_free (auth_part);
fsp_session_set_http_proxy (priv->session, host, port, username, password);
diff --git a/src/frogr-global-defs.h b/src/frogr-global-defs.h
index ebf7cc4..75e52be 100644
--- a/src/frogr-global-defs.h
+++ b/src/frogr-global-defs.h
@@ -29,4 +29,10 @@
#define APP_SHORTNAME PACKAGE
#define APP_VERSION VERSION
+#ifdef DEBUG_ENABLED
+#define DEBUG(...) g_debug (__VA_ARGS__);
+#else
+#define DEBUG(...)
+#endif
+
#endif
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 75016f5..2f25474 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -660,9 +660,9 @@ _on_account_menu_item_activate (GtkWidget *widget, gpointer self)
if (account && FROGR_IS_ACCOUNT (account))
{
frogr_controller_set_active_account (priv->controller, account);
- g_debug ("Selected account %s (%s)",
- frogr_account_get_id (account),
- frogr_account_get_username (account));
+ DEBUG ("Selected account %s (%s)",
+ frogr_account_get_id (account),
+ frogr_account_get_username (account));
}
}
@@ -1088,7 +1088,7 @@ _controller_active_account_changed (FrogrController *controller,
if (frogr_controller_get_state (priv->controller) != FROGR_STATE_BUSY)
frogr_main_view_set_status_text (mainview, description);
- g_debug ("Account details changed: %s", description);
+ DEBUG ("Account details changed: %s", description);
g_free (description);
}
@@ -1103,7 +1103,7 @@ _controller_accounts_changed (FrogrController *controller,
_populate_accounts_submenu (mainview);
_update_ui (mainview);
- g_debug ("%s", "Accounts list changed");
+ DEBUG ("%s", "Accounts list changed");
}
static void
diff --git a/src/frogr-picture-loader.c b/src/frogr-picture-loader.c
index 3cd508f..e5bb942 100644
--- a/src/frogr-picture-loader.c
+++ b/src/frogr-picture-loader.c
@@ -24,6 +24,7 @@
#include "frogr-config.h"
#include "frogr-controller.h"
+#include "frogr-global-defs.h"
#include "frogr-main-view.h"
#include "frogr-picture.h"
@@ -160,7 +161,7 @@ _load_next_picture (FrogrPictureLoader *self)
}
}
- g_debug ("Adding file %s (%s)", filepath, mime_type);
+ DEBUG ("Adding file %s (%s)", filepath, mime_type);
g_object_unref (file_info);
/* Asynchronously load the picture if mime is valid */
diff --git a/src/frogr-settings-dialog.c b/src/frogr-settings-dialog.c
index 442e3bf..b71a31b 100644
--- a/src/frogr-settings-dialog.c
+++ b/src/frogr-settings-dialog.c
@@ -24,6 +24,7 @@
#include "frogr-config.h"
#include "frogr-controller.h"
+#include "frogr-global-defs.h"
#include "frogr-util.h"
#include <config.h>
@@ -544,67 +545,67 @@ _on_button_toggled (GtkToggleButton *button, gpointer data)
if (GTK_WIDGET (button) == priv->public_rb)
{
priv->public_visibility = active;
- g_debug ("general visibility set to %s", active ? "Public" : "Private");
+ DEBUG ("general visibility set to %s", active ? "Public" : "Private");
}
if (GTK_WIDGET (button) == priv->family_cb)
{
priv->family_visibility = active;
- g_debug ("family visibility set to %s", active ? "TRUE" : "FALSE");
+ DEBUG ("family visibility set to %s", active ? "TRUE" : "FALSE");
}
if (GTK_WIDGET (button) == priv->friend_cb)
{
priv->friend_visibility = active;
- g_debug ("friend visibility set to %s", active ? "TRUE" : "FALSE");
+ DEBUG ("friend visibility set to %s", active ? "TRUE" : "FALSE");
}
if (GTK_WIDGET (button) == priv->show_in_search_cb)
{
priv->show_in_search = active;
- g_debug ("Show up in global search results set to %s", active ? "TRUE" : "FALSE");
+ DEBUG ("Show up in global search results set to %s", active ? "TRUE" : "FALSE");
}
if (active && GTK_WIDGET (button) == priv->photo_content_rb)
{
priv->content_type = FSP_CONTENT_TYPE_PHOTO;
- g_debug ("Content type set to %d", priv->content_type);
+ DEBUG ("Content type set to %d", priv->content_type);
}
if (active && GTK_WIDGET (button) == priv->sshot_content_rb)
{
priv->content_type = FSP_CONTENT_TYPE_SCREENSHOT;
- g_debug ("Content type set to %d", priv->content_type);
+ DEBUG ("Content type set to %d", priv->content_type);
}
if (active && GTK_WIDGET (button) == priv->other_content_rb)
{
priv->content_type = FSP_CONTENT_TYPE_OTHER;
- g_debug ("Content type set to %d", priv->content_type);
+ DEBUG ("Content type set to %d", priv->content_type);
}
if (active && GTK_WIDGET (button) == priv->safe_rb)
{
priv->safety_level = FSP_SAFETY_LEVEL_SAFE;
- g_debug ("Content type set to %d", priv->safety_level);
+ DEBUG ("Content type set to %d", priv->safety_level);
}
if (active && GTK_WIDGET (button) == priv->moderate_rb)
{
priv->safety_level = FSP_SAFETY_LEVEL_MODERATE;
- g_debug ("Content type set to %d", priv->safety_level);
+ DEBUG ("Content type set to %d", priv->safety_level);
}
if (active && GTK_WIDGET (button) == priv->restricted_rb)
{
priv->safety_level = FSP_SAFETY_LEVEL_RESTRICTED;
- g_debug ("Content type set to %d", priv->safety_level);
+ DEBUG ("Content type set to %d", priv->safety_level);
}
if (GTK_WIDGET (button) == priv->use_proxy_cb)
{
priv->use_proxy = active;
- g_debug ("Use HTTP proxy: %s", active ? "YES" : "NO");
+ DEBUG ("Use HTTP proxy: %s", active ? "YES" : "NO");
}
_update_ui (self);
diff --git a/src/frogr-util.c b/src/frogr-util.c
index 2cb3dc4..b07e553 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -44,7 +44,7 @@ frogr_util_open_url_in_browser (const gchar *url)
if (error != NULL)
{
- g_debug ("Error opening URL %s: %s", url, error->message);
+ DEBUG ("Error opening URL %s: %s", url, error->message);
g_error_free (error);
}
}
diff --git a/src/main.c b/src/main.c
index f0e1466..2252d76 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,7 +50,7 @@ _get_paths_list_from_array (char **paths_str, int n_paths)
filepath = g_filename_from_uri (uri, NULL, &err);
if (err)
{
- g_debug ("Error loading picture %s: %s\n", uri, err->message);
+ DEBUG ("Error loading picture %s: %s\n", uri, err->message);
g_error_free (err);
err = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]