make debugging messages runtime activated, instead of through a -DDEBUG

parent 38f16d96
2006-02-14 Gustavo J. A. M. Carneiro <gjc@gnome.org>
* src/nautilus-python.c,
* src/nautilus-python.h: Make debugging messages be activated
through the environment variable NAUTILUS_PYTHON_DEBUG, instead of
the DEBUG preprocessor macro.
=== 0.4.2 ===
2006-02-10 Gustavo J. A. M. Carneiro <gjc@gnome.org>
......
......@@ -31,6 +31,12 @@
#include <libnautilus-extension/nautilus-extension-types.h>
static const GDebugKey nautilus_python_debug_keys[] = {
{"misc", NAUTILUS_PYTHON_DEBUG_MISC},
};
static const guint nautilus_python_ndebug_keys = sizeof (nautilus_python_debug_keys) / sizeof (GDebugKey);
NautilusPythonDebug nautilus_python_debug;
static GArray *all_types = NULL;
#define ENTRY_POINT "nautilus_extension_types"
......@@ -205,6 +211,15 @@ void
nautilus_module_initialize(GTypeModule *module)
{
gchar *user_extensions_dir;
const gchar *env_string;
env_string = g_getenv("NAUTILUS_PYTHON_DEBUG");
if (env_string != NULL) {
nautilus_python_debug = g_parse_debug_string(env_string,
nautilus_python_debug_keys,
nautilus_python_ndebug_keys);
env_string = NULL;
}
debug_enter();
......
......@@ -23,17 +23,21 @@
#define NAUTILUS_PYTHON_H
#include <glib-object.h>
#include <glib/gprintf.h>
#include <Python.h>
#ifdef DEBUG
# define debug(x) (g_printf( "nautilus-python:" x "\n"))
# define debug_enter() (g_printf("%s: entered\n", __FUNCTION__))
# define debug_enter_args(x, y) (g_printf("%s: entered " x "\n", __FUNCTION__, y))
#else
# define debug(x)
# define debug_enter()
# define debug_enter_args(x, y)
#endif
typedef enum {
NAUTILUS_PYTHON_DEBUG_MISC = 1 << 0,
} NautilusPythonDebug;
extern NautilusPythonDebug nautilus_python_debug;
#define debug(x) { if (nautilus_python_debug & NAUTILUS_PYTHON_DEBUG_MISC) \
g_printf( "nautilus-python:" x "\n"); }
#define debug_enter() { if (nautilus_python_debug & NAUTILUS_PYTHON_DEBUG_MISC) \
g_printf("%s: entered\n", __FUNCTION__); }
#define debug_enter_args(x, y) { if (nautilus_python_debug & NAUTILUS_PYTHON_DEBUG_MISC) \
g_printf("%s: entered " x "\n", __FUNCTION__, y); }
/* Macros from PyGTK, changed to return FALSE instead of nothing */
#define np_init_pygobject() { \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment