diff options
author | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2011-05-30 11:10:08 +0100 |
---|---|---|
committer | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2011-06-01 16:34:12 +0100 |
commit | eaae4ff6dab43a52584487eec5d8d39b74209db5 (patch) | |
tree | a105aa7e92ffbd36a8ef29e01e811b9d9577d12f | |
parent | e17b83fec8f01ca6977cb4fe259a83634aa90b26 (diff) | |
download | telepathy-mission-control-eaae4ff6dab43a52584487eec5d8d39b74209db5.tar.gz |
New debug control for mission-control-plugins
-rw-r--r-- | mission-control-plugins/Makefile.am | 2 | ||||
-rw-r--r-- | mission-control-plugins/debug.c | 66 | ||||
-rw-r--r-- | mission-control-plugins/debug.h | 43 |
3 files changed, 111 insertions, 0 deletions
diff --git a/mission-control-plugins/Makefile.am b/mission-control-plugins/Makefile.am index 513aab64..cbd08e17 100644 --- a/mission-control-plugins/Makefile.am +++ b/mission-control-plugins/Makefile.am @@ -44,6 +44,8 @@ nodist_libmission_control_plugins_la_SOURCES = \ libmission_control_plugins_la_SOURCES = \ debug-internal.h \ + debug.h \ + debug.c \ account.c \ account-storage.c \ dbus-acl.c \ diff --git a/mission-control-plugins/debug.c b/mission-control-plugins/debug.c new file mode 100644 index 00000000..8b34f271 --- /dev/null +++ b/mission-control-plugins/debug.c @@ -0,0 +1,66 @@ +/* Mission Control plugin API - plugin debug infrastructure + * + * Copyright © 2011 Nokia Corporation + * Copyright © 2011 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <mission-control-plugins/mission-control-plugins.h> +#include <mission-control-plugins/debug.h> +#include <config.h> + +static McpDebugFlags debug_flags; + +static GDebugKey const keys[] = { + { "account", MCP_DEBUG_ACCOUNT }, + { "account-storage", MCP_DEBUG_ACCOUNT_STORAGE }, + { "dbus-acl", MCP_DEBUG_DBUS_ACL }, + { "dispatch-operation", MCP_DEBUG_DISPATCH_OPERATION }, + { "dispatch-operation-policy", MCP_DEBUG_DISPATCH_OPERATION_POLICY }, + { "loader", MCP_DEBUG_LOADER }, + { "request", MCP_DEBUG_REQUEST }, + { "request-policy", MCP_DEBUG_REQUEST_POLICY }, + { NULL, 0 } +}; + +void +mcp_debug_init (void) +{ + const gchar *p_debug = g_getenv ("MCP_DEBUG"); + const gchar *d_debug = g_getenv ("MC_DEBUG"); + const gchar *debug = NULL; + + debug_flags = MCP_DEBUG_NONE; + + if (p_debug != NULL) + debug = p_debug; + else if (g_strcmp0 ("all", d_debug) == 0) + debug = d_debug; + else + return; + + debug_flags = g_parse_debug_string (debug, keys, G_N_ELEMENTS (keys) - 1); +} + +gboolean +mcp_is_debugging (McpDebugFlags flags) +{ +#ifdef ENABLE_DEBUG + return (flags & debug_flags) != 0; +#else + return FALSE; +#endif +} diff --git a/mission-control-plugins/debug.h b/mission-control-plugins/debug.h new file mode 100644 index 00000000..14a52099 --- /dev/null +++ b/mission-control-plugins/debug.h @@ -0,0 +1,43 @@ +/* Mission Control plugin API - for plugin debug messages + * + * Copyright © 2011 Nokia Corporation + * Copyright © 2011 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MCP_DEBUG_H +#define MCP_DEBUG_H + +G_BEGIN_DECLS + +typedef enum { + MCP_DEBUG_NONE = 0, + MCP_DEBUG_ACCOUNT = 1 << 0, + MCP_DEBUG_ACCOUNT_STORAGE = 1 << 1, + MCP_DEBUG_DBUS_ACL = 1 << 2, + MCP_DEBUG_DISPATCH_OPERATION = 1 << 3, + MCP_DEBUG_DISPATCH_OPERATION_POLICY = 1 << 4, + MCP_DEBUG_LOADER = 1 << 5, + MCP_DEBUG_REQUEST = 1 << 6, + MCP_DEBUG_REQUEST_POLICY = 1 << 7, +} McpDebugFlags; + +gboolean mcp_is_debugging (McpDebugFlags type); +void mcp_debug_init (void); + +G_END_DECLS + +#endif |