summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Dasmohapatra <vivek@collabora.co.uk>2011-05-19 21:26:58 +0100
committerVivek Dasmohapatra <vivek@collabora.co.uk>2011-06-01 16:34:19 +0100
commitcb25b3900d439e8a998e948c588d16a7888027a1 (patch)
tree8a721dd39b76b708ce8df5c9ab742c788d868654
parenteaae4ff6dab43a52584487eec5d8d39b74209db5 (diff)
downloadtelepathy-mission-control-cb25b3900d439e8a998e948c588d16a7888027a1.tar.gz
Use the new environment-driven debug control mechanism in MCP
-rw-r--r--mission-control-plugins/account-storage.c28
-rw-r--r--mission-control-plugins/account.c3
-rw-r--r--mission-control-plugins/dbus-acl.c22
-rw-r--r--mission-control-plugins/debug-internal.h25
-rw-r--r--mission-control-plugins/loader.c26
5 files changed, 40 insertions, 64 deletions
diff --git a/mission-control-plugins/account-storage.c b/mission-control-plugins/account-storage.c
index b4eaaeef..354f121e 100644
--- a/mission-control-plugins/account-storage.c
+++ b/mission-control-plugins/account-storage.c
@@ -78,18 +78,20 @@
#include <mission-control-plugins/mission-control-plugins.h>
#include <mission-control-plugins/mcp-signals-marshal.h>
#include <mission-control-plugins/implementation.h>
+#include <mission-control-plugins/debug-internal.h>
#include <glib.h>
+#define MCP_DEBUG_TYPE MCP_DEBUG_ACCOUNT_STORAGE
+
#ifdef ENABLE_DEBUG
-#define DEBUG(_p, _format, ...) \
- if (g_getenv ("MC_STORAGE_DEBUG") != NULL) \
- g_debug ("%s: %s: " _format, G_STRFUNC, \
+#define SDEBUG(_p, _format, ...) \
+ DEBUG("%s: " _format, \
(_p != NULL) ? mcp_account_storage_name (_p) : "NULL", ##__VA_ARGS__)
#else /* ENABLE_DEBUG */
-#define DEBUG(_p, _format, ...) do {} while (0);
+#define SDEBUG(_p, _format, ...) do {} while (0);
#endif /* ENABLE_DEBUG */
@@ -397,7 +399,7 @@ mcp_account_storage_get (const McpAccountStorage *storage,
{
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
- DEBUG (storage, "");
+ SDEBUG (storage, "");
g_return_val_if_fail (iface != NULL, FALSE);
return iface->get (storage, am, account, key);
@@ -429,7 +431,7 @@ mcp_account_storage_set (const McpAccountStorage *storage,
{
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
- DEBUG (storage, "");
+ SDEBUG (storage, "");
g_return_val_if_fail (iface != NULL, FALSE);
return iface->set (storage, am, account, key, val);
@@ -466,7 +468,7 @@ mcp_account_storage_delete (const McpAccountStorage *storage,
{
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
- DEBUG (storage, "");
+ SDEBUG (storage, "");
g_return_val_if_fail (iface != NULL, FALSE);
return iface->delete (storage, am, account, key);
@@ -498,7 +500,7 @@ mcp_account_storage_commit (const McpAccountStorage *storage,
{
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
- DEBUG (storage, "committing all accounts");
+ SDEBUG (storage, "committing all accounts");
g_return_val_if_fail (iface != NULL, FALSE);
if (iface->commit != NULL)
@@ -511,7 +513,7 @@ mcp_account_storage_commit (const McpAccountStorage *storage,
}
else
{
- DEBUG (storage,
+ SDEBUG (storage,
"neither commit nor commit_one is implemented; cannot save accounts");
return FALSE;
}
@@ -538,7 +540,7 @@ mcp_account_storage_commit_one (const McpAccountStorage *storage,
{
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
- DEBUG (storage, "called for %s", account ? account : "<all accounts>");
+ SDEBUG (storage, "called for %s", account ? account : "<all accounts>");
g_return_val_if_fail (iface != NULL, FALSE);
if (iface->commit_one != NULL)
@@ -566,7 +568,7 @@ mcp_account_storage_list (const McpAccountStorage *storage,
{
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
- DEBUG (storage, "");
+ SDEBUG (storage, "");
g_return_val_if_fail (iface != NULL, NULL);
return iface->list (storage, am);
@@ -612,7 +614,7 @@ mcp_account_storage_get_identifier (const McpAccountStorage *storage,
{
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
- DEBUG (storage, "");
+ SDEBUG (storage, "");
g_return_if_fail (iface != NULL);
g_return_if_fail (identifier != NULL);
g_return_if_fail (!G_IS_VALUE (identifier));
@@ -646,7 +648,7 @@ mcp_account_storage_get_additional_info (const McpAccountStorage *storage,
McpAccountStorageIface *iface = MCP_ACCOUNT_STORAGE_GET_IFACE (storage);
GHashTable *ret = NULL;
- DEBUG (storage, "");
+ SDEBUG (storage, "");
g_return_val_if_fail (iface != NULL, FALSE);
if (iface->get_additional_info != NULL)
diff --git a/mission-control-plugins/account.c b/mission-control-plugins/account.c
index fda29e4a..849c3204 100644
--- a/mission-control-plugins/account.c
+++ b/mission-control-plugins/account.c
@@ -20,6 +20,9 @@
#include <mission-control-plugins/mission-control-plugins.h>
#include <mission-control-plugins/implementation.h>
+#include <mission-control-plugins/debug-internal.h>
+
+#define MCP_DEBUG_TYPE MCP_DEBUG_ACCOUNT
/**
* SECTION:account
diff --git a/mission-control-plugins/dbus-acl.c b/mission-control-plugins/dbus-acl.c
index 4c1a2663..82ef0a27 100644
--- a/mission-control-plugins/dbus-acl.c
+++ b/mission-control-plugins/dbus-acl.c
@@ -58,22 +58,16 @@
#include "config.h"
#include <mission-control-plugins/mission-control-plugins.h>
+#include <mission-control-plugins/debug-internal.h>
#include <mission-control-plugins/mcp-signals-marshal.h>
#include <glib.h>
#include <telepathy-glib/telepathy-glib.h>
-#ifdef ENABLE_DEBUG
-
-#define DEBUG(_p, _format, ...) \
- g_debug ("dbus-acl: %s: %s: " _format, G_STRFUNC, \
+#define MCP_DEBUG_TYPE MCP_DEBUG_DBUS_ACL
+#define ACL_DEBUG(_p, _format, ...) \
+ DEBUG("%s: " _format, \
(_p != NULL) ? mcp_dbus_acl_name (_p) : "-", ##__VA_ARGS__)
-#else /* ENABLE_DEBUG */
-
-#define DEBUG(_p, _format, ...) do {} while (0);
-
-#endif /* ENABLE_DEBUG */
-
/**
* McpDBusAclIface:
* @parent: the parent type
@@ -266,7 +260,7 @@ mcp_dbus_acl_authorised (const TpDBusDaemon *dbus,
McpDBusAcl *plugin = MCP_DBUS_ACL (p->data);
McpDBusAclIface *iface = MCP_DBUS_ACL_GET_IFACE (p->data);
- DEBUG (plugin, "checking ACL for %s", name);
+ ACL_DEBUG (plugin, "checking ACL for %s", name);
if (iface->authorised != NULL)
permitted = iface->authorised (plugin, dbus, context, type, name, params);
@@ -312,7 +306,7 @@ mcp_dbus_acl_authorised_async_step (DBusAclAuthData *ad,
McpDBusAclIface *iface = MCP_DBUS_ACL_GET_IFACE (plugin);
if (ad->acl != NULL)
- DEBUG (ad->acl, "passed ACL for %s", ad->name);
+ ACL_DEBUG (ad->acl, "passed ACL for %s", ad->name);
/* take the next plugin off the next_acl list */
ad->next_acl = g_list_next (ad->next_acl);
@@ -330,7 +324,7 @@ mcp_dbus_acl_authorised_async_step (DBusAclAuthData *ad,
}
if (ad->acl != NULL)
- DEBUG (ad->acl, "passed final ACL for %s", ad->name);
+ ACL_DEBUG (ad->acl, "passed final ACL for %s", ad->name);
ad->handler (ad->context, ad->data);
}
@@ -403,7 +397,7 @@ mcp_dbus_acl_authorised_async (TpDBusDaemon *dbus,
ad->handler = handler;
ad->next_acl = acls;
- DEBUG (NULL, "DBus access ACL verification: %u rules for %s",
+ ACL_DEBUG (NULL, "DBus access ACL verification: %u rules for %s",
g_list_length (acls),
name);
mcp_dbus_acl_authorised_async_step (ad, TRUE);
diff --git a/mission-control-plugins/debug-internal.h b/mission-control-plugins/debug-internal.h
index ff6440c4..d150e6c7 100644
--- a/mission-control-plugins/debug-internal.h
+++ b/mission-control-plugins/debug-internal.h
@@ -24,31 +24,22 @@
#include "config.h"
#include <glib.h>
+#include <mission-control-plugins/debug.h>
-G_BEGIN_DECLS
-
-gboolean _mcp_is_debugging (void);
-void _mcp_debug (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
-
-G_END_DECLS
+#ifdef DEBUG
+#undef DEBUG
+#endif
#ifdef ENABLE_DEBUG
-#undef DEBUG
#define DEBUG(format, ...) \
- _mcp_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
+ if (mcp_debugging (MCP_DEBUG_TYPE)) \
+ g_debug ("%s: " format, G_STRLOC, ##__VA_ARGS__)
-#undef DEBUGGING
-#define DEBUGGING _mcp_is_debugging ()
+#else
-#else /* !defined (ENABLE_DEBUG) */
-
-#undef DEBUG
#define DEBUG(format, ...) do {} while (0)
-#undef DEBUGGING
-#define DEBUGGING 0
-
-#endif /* !defined (ENABLE_DEBUG) */
+#endif
#endif
diff --git a/mission-control-plugins/loader.c b/mission-control-plugins/loader.c
index 78765f46..4336c082 100644
--- a/mission-control-plugins/loader.c
+++ b/mission-control-plugins/loader.c
@@ -43,10 +43,15 @@
#include <gmodule.h>
#include <mission-control-plugins/mission-control-plugins.h>
-#include <mission-control-plugins/debug-internal.h>
+#include <mission-control-plugins/debug.h>
static gboolean debugging = FALSE;
+#undef DEBUG
+#define DEBUG(format, ...) \
+ G_STMT_START { if (debugging || mcp_is_debugging (MCP_DEBUG_LOADER)) \
+ g_debug ("%s" format, G_STRLOC, ##__VA_ARGS__); } G_STMT_END
+
/**
* mcp_set_debug:
* @debug: whether to log debug output
@@ -60,25 +65,6 @@ mcp_set_debug (gboolean debug)
debugging = debug;
}
-gboolean
-_mcp_is_debugging (void)
-{
- return debugging;
-}
-
-void
-_mcp_debug (const gchar *format, ...)
-{
- if (debugging)
- {
- va_list args;
-
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
- va_end (args);
- }
-}
-
static GList *plugins = NULL;
/**