1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
4 * (GLABELS) Label and Business Card Creation program for GNOME
6 * debug.c: GLabels debug module
8 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * This file is based on gedit-debug.c from gedit2:
28 * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
29 * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
35 #include <glib/gutils.h>
36 #include <glib/gmessages.h>
37 #include <glib/gstrfuncs.h>
38 #include <glib/gmem.h>
40 glDebugSection debug_flags = GLABELS_DEBUG_NONE;
42 /****************************************************************************/
43 /* Initialize debug flags, based on environmental variables. */
44 /****************************************************************************/
48 if (g_getenv ("GLABELS_DEBUG") != NULL)
50 /* enable all debugging */
51 debug_flags = ~GLABELS_DEBUG_NONE;
55 if (g_getenv ("GLABELS_DEBUG_VIEW") != NULL)
56 debug_flags |= GLABELS_DEBUG_VIEW;
57 if (g_getenv ("GLABELS_DEBUG_ITEM") != NULL)
58 debug_flags |= GLABELS_DEBUG_ITEM;
59 if (g_getenv ("GLABELS_DEBUG_PRINT") != NULL)
60 debug_flags |= GLABELS_DEBUG_PRINT;
61 if (g_getenv ("GLABELS_DEBUG_PREFS") != NULL)
62 debug_flags |= GLABELS_DEBUG_PREFS;
63 if (g_getenv ("GLABELS_DEBUG_FILE") != NULL)
64 debug_flags |= GLABELS_DEBUG_FILE;
65 if (g_getenv ("GLABELS_DEBUG_LABEL") != NULL)
66 debug_flags |= GLABELS_DEBUG_LABEL;
67 if (g_getenv ("GLABELS_DEBUG_TEMPLATE") != NULL)
68 debug_flags |= GLABELS_DEBUG_TEMPLATE;
69 if (g_getenv ("GLABELS_DEBUG_PAPER") != NULL)
70 debug_flags |= GLABELS_DEBUG_PAPER;
71 if (g_getenv ("GLABELS_DEBUG_XML") != NULL)
72 debug_flags |= GLABELS_DEBUG_XML;
73 if (g_getenv ("GLABELS_DEBUG_MERGE") != NULL)
74 debug_flags |= GLABELS_DEBUG_MERGE;
75 if (g_getenv ("GLABELS_DEBUG_UNDO") != NULL)
76 debug_flags |= GLABELS_DEBUG_UNDO;
77 if (g_getenv ("GLABELS_DEBUG_RECENT") != NULL)
78 debug_flags |= GLABELS_DEBUG_RECENT;
79 if (g_getenv ("GLABELS_DEBUG_COMMANDS") != NULL)
80 debug_flags |= GLABELS_DEBUG_COMMANDS;
81 if (g_getenv ("GLABELS_DEBUG_WINDOW") != NULL)
82 debug_flags |= GLABELS_DEBUG_WINDOW;
83 if (g_getenv ("GLABELS_DEBUG_UI") != NULL)
84 debug_flags |= GLABELS_DEBUG_UI;
85 if (g_getenv ("GLABELS_DEBUG_PROPERTY_BAR") != NULL)
86 debug_flags |= GLABELS_DEBUG_PROPERTY_BAR;
87 if (g_getenv ("GLABELS_DEBUG_MEDIA_SELECT") != NULL)
88 debug_flags |= GLABELS_DEBUG_MEDIA_SELECT;
89 if (g_getenv ("GLABELS_DEBUG_MINI_PREVIEW") != NULL)
90 debug_flags |= GLABELS_DEBUG_MINI_PREVIEW;
91 if (g_getenv ("GLABELS_DEBUG_PIXBUF_CACHE") != NULL)
92 debug_flags |= GLABELS_DEBUG_PIXBUF_CACHE;
93 if (g_getenv ("GLABELS_DEBUG_EDITOR") != NULL)
94 debug_flags |= GLABELS_DEBUG_EDITOR;
95 if (g_getenv ("GLABELS_DEBUG_WDGT") != NULL)
96 debug_flags |= GLABELS_DEBUG_WDGT;
97 if (g_getenv ("GLABELS_DEBUG_PATH") != NULL)
98 debug_flags |= GLABELS_DEBUG_PATH;
102 /****************************************************************************/
103 /* Print debugging information. */
104 /****************************************************************************/
106 gl_debug (glDebugSection section,
109 const gchar *function,
113 if (debug_flags & section)
118 g_return_if_fail (format != NULL);
120 va_start (args, format);
121 msg = g_strdup_vprintf (format, args);
124 g_print ("%s:%d (%s) %s\n", file, line, function, msg);