]> git.sur5r.net Git - glabels/blob - glabels2/src/debug.c
Initial revision
[glabels] / glabels2 / src / debug.c
1 /*
2  *  (GLABELS) Label and Business Card Creation program for GNOME
3  *
4  *  debug.c:  GLabels debug module
5  *
6  *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  */
22
23 /*
24  * This file is based on gedit-debug.c from gedit2:
25  *
26  * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
27  * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi 
28  *
29  */
30 #include <glib.h>
31
32 #include "debug.h"
33
34 /* External debug options, used here and in glabels.c */
35 gint gl_debug_all = 0;
36 gint gl_debug_view = 0;
37 gint gl_debug_item = 0;
38 gint gl_debug_prefs = 0;
39 gint gl_debug_print = 0;
40 gint gl_debug_file = 0;
41 gint gl_debug_label = 0;
42 gint gl_debug_template = 0;
43 gint gl_debug_xml = 0;
44 gint gl_debug_merge = 0;
45 gint gl_debug_commands = 0;
46 gint gl_debug_undo = 0;
47 gint gl_debug_recent = 0;
48 gint gl_debug_mdi = 0;
49 gint gl_debug_media_select = 0;
50 gint gl_debug_mini_preview = 0;
51 gint gl_debug_wdgt = 0;
52
53 /****************************************************************************/
54 /* Print debugging information.                                             */
55 /****************************************************************************/
56 void
57 gl_debug (gint section,
58           gchar *file,
59           gint line,
60           gchar* function,
61           gchar* format,
62           ...)
63 {
64         va_list args;
65         gchar *msg;
66
67         g_return_if_fail (format != NULL);
68
69         va_start (args, format);
70         msg = g_strdup_vprintf (format, args);
71         va_end (args);
72
73         if (gl_debug_all ||
74             (gl_debug_view         && section == GL_DEBUG_VIEW)           ||
75             (gl_debug_item         && section == GL_DEBUG_ITEM)           ||
76             (gl_debug_print        && section == GL_DEBUG_PRINT)          ||
77             (gl_debug_prefs        && section == GL_DEBUG_PREFS)          ||
78             (gl_debug_file         && section == GL_DEBUG_FILE)           ||
79             (gl_debug_label        && section == GL_DEBUG_LABEL)          ||
80             (gl_debug_template     && section == GL_DEBUG_TEMPLATE)       ||
81             (gl_debug_xml          && section == GL_DEBUG_XML)            ||
82             (gl_debug_merge        && section == GL_DEBUG_MERGE)          ||
83             (gl_debug_commands     && section == GL_DEBUG_COMMANDS)       ||
84             (gl_debug_undo         && section == GL_DEBUG_UNDO)           ||
85             (gl_debug_recent       && section == GL_DEBUG_RECENT)         ||
86             (gl_debug_mdi          && section == GL_DEBUG_MDI)            ||
87             (gl_debug_media_select && section == GL_DEBUG_MEDIA_SELECT)   ||
88             (gl_debug_mini_preview && section == GL_DEBUG_MINI_PREVIEW)   ||
89             (gl_debug_wdgt         && section == GL_DEBUG_WDGT) )
90                 g_print ("%s:%d (%s) %s\n", file, line, function, msg);
91         
92         g_free (msg);
93 }