3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
22 * This file is based on gedit-debug.c from gedit2:
24 * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
25 * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
34 glDebugSection debug_flags = GLABELS_DEBUG_NONE;
37 /****************************************************************************/
38 /* Initialize debug flags, based on environmental variables. */
39 /****************************************************************************/
43 if (g_getenv ("GLABELS_DEBUG") != NULL)
45 /* enable all debugging */
46 debug_flags = ~GLABELS_DEBUG_NONE;
50 if (g_getenv ("GLABELS_DEBUG_VIEW") != NULL)
51 debug_flags |= GLABELS_DEBUG_VIEW;
52 if (g_getenv ("GLABELS_DEBUG_ITEM") != NULL)
53 debug_flags |= GLABELS_DEBUG_ITEM;
54 if (g_getenv ("GLABELS_DEBUG_PRINT") != NULL)
55 debug_flags |= GLABELS_DEBUG_PRINT;
56 if (g_getenv ("GLABELS_DEBUG_PREFS") != NULL)
57 debug_flags |= GLABELS_DEBUG_PREFS;
58 if (g_getenv ("GLABELS_DEBUG_FILE") != NULL)
59 debug_flags |= GLABELS_DEBUG_FILE;
60 if (g_getenv ("GLABELS_DEBUG_LABEL") != NULL)
61 debug_flags |= GLABELS_DEBUG_LABEL;
62 if (g_getenv ("GLABELS_DEBUG_TEMPLATE") != NULL)
63 debug_flags |= GLABELS_DEBUG_TEMPLATE;
64 if (g_getenv ("GLABELS_DEBUG_PAPER") != NULL)
65 debug_flags |= GLABELS_DEBUG_PAPER;
66 if (g_getenv ("GLABELS_DEBUG_XML") != NULL)
67 debug_flags |= GLABELS_DEBUG_XML;
68 if (g_getenv ("GLABELS_DEBUG_MERGE") != NULL)
69 debug_flags |= GLABELS_DEBUG_MERGE;
70 if (g_getenv ("GLABELS_DEBUG_UNDO") != NULL)
71 debug_flags |= GLABELS_DEBUG_UNDO;
72 if (g_getenv ("GLABELS_DEBUG_RECENT") != NULL)
73 debug_flags |= GLABELS_DEBUG_RECENT;
74 if (g_getenv ("GLABELS_DEBUG_COMMANDS") != NULL)
75 debug_flags |= GLABELS_DEBUG_COMMANDS;
76 if (g_getenv ("GLABELS_DEBUG_WINDOW") != NULL)
77 debug_flags |= GLABELS_DEBUG_WINDOW;
78 if (g_getenv ("GLABELS_DEBUG_UI") != NULL)
79 debug_flags |= GLABELS_DEBUG_UI;
80 if (g_getenv ("GLABELS_DEBUG_PROPERTY_BAR") != NULL)
81 debug_flags |= GLABELS_DEBUG_PROPERTY_BAR;
82 if (g_getenv ("GLABELS_DEBUG_MEDIA_SELECT") != NULL)
83 debug_flags |= GLABELS_DEBUG_MEDIA_SELECT;
84 if (g_getenv ("GLABELS_DEBUG_MINI_PREVIEW") != NULL)
85 debug_flags |= GLABELS_DEBUG_MINI_PREVIEW;
86 if (g_getenv ("GLABELS_DEBUG_PIXBUF_CACHE") != NULL)
87 debug_flags |= GLABELS_DEBUG_PIXBUF_CACHE;
88 if (g_getenv ("GLABELS_DEBUG_SVG_CACHE") != NULL)
89 debug_flags |= GLABELS_DEBUG_SVG_CACHE;
90 if (g_getenv ("GLABELS_DEBUG_EDITOR") != NULL)
91 debug_flags |= GLABELS_DEBUG_EDITOR;
92 if (g_getenv ("GLABELS_DEBUG_WDGT") != NULL)
93 debug_flags |= GLABELS_DEBUG_WDGT;
94 if (g_getenv ("GLABELS_DEBUG_PATH") != NULL)
95 debug_flags |= GLABELS_DEBUG_PATH;
96 if (g_getenv ("GLABELS_DEBUG_FIELD_BUTTON") != NULL)
97 debug_flags |= GLABELS_DEBUG_FIELD_BUTTON;
98 if (g_getenv ("GLABELS_DEBUG_BARCODE") != NULL)
99 debug_flags |= GLABELS_DEBUG_BARCODE;
103 /****************************************************************************/
104 /* Print debugging information. */
105 /****************************************************************************/
107 gl_debug (glDebugSection section,
110 const gchar *function,
114 if (debug_flags & section)
119 g_return_if_fail (format != NULL);
121 va_start (args, format);
122 msg = g_strdup_vprintf (format, args);
125 g_print ("%s:%d (%s) %s\n", file, line, function, msg);
135 * Local Variables: -- emacs
137 * c-basic-offset: 8 -- emacs
138 * tab-width: 8 -- emacs
139 * indent-tabs-mode: nil -- emacs