1 /*
2  * nemo-debug: debug loggers for nemo
3  *
4  * Copyright (C) 2007 Collabora Ltd.
5  * Copyright (C) 2007 Nokia Corporation
6  * Copyright (C) 2010 Red Hat, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library 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 GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  * Based on Empathy's empathy-debug.
23  */
24 
25 #ifndef __NEMO_DEBUG_H__
26 #define __NEMO_DEBUG_H__
27 
28 #include <config.h>
29 #include <glib.h>
30 
31 G_BEGIN_DECLS
32 
33 #ifdef ENABLE_DEBUG
34 
35 typedef enum {
36   NEMO_DEBUG_APPLICATION = 1 << 1,
37   NEMO_DEBUG_BOOKMARKS = 1 << 2,
38   NEMO_DEBUG_DBUS = 1 << 3,
39   NEMO_DEBUG_DIRECTORY_VIEW = 1 << 4,
40   NEMO_DEBUG_FILE = 1 << 5,
41   NEMO_DEBUG_ICON_CONTAINER = 1 << 6,
42   NEMO_DEBUG_ICON_VIEW = 1 << 7,
43   NEMO_DEBUG_LIST_VIEW = 1 << 8,
44   NEMO_DEBUG_MIME = 1 << 9,
45   NEMO_DEBUG_PLACES = 1 << 10,
46   NEMO_DEBUG_PREVIEWER = 1 << 11,
47   NEMO_DEBUG_SMCLIENT = 1 << 12,
48   NEMO_DEBUG_WINDOW = 1 << 13,
49   NEMO_DEBUG_UNDO = 1 << 14,
50   NEMO_DEBUG_ACTIONS = 1 << 15,
51   NEMO_DEBUG_DESKTOP = 1 << 16,
52   NEMO_DEBUG_THUMBNAILS = 1 << 17
53 } DebugFlags;
54 
55 void nemo_debug_set_flags (DebugFlags flags);
56 gboolean nemo_debug_flag_is_set (DebugFlags flag);
57 
58 void nemo_debug_valist (DebugFlags flag,
59                             const gchar *format, va_list args);
60 
61 void nemo_debug (DebugFlags flag, const gchar *format, ...)
62   G_GNUC_PRINTF (2, 3);
63 
64 void nemo_debug_files (DebugFlags flag, GList *files,
65                            const gchar *format, ...) G_GNUC_PRINTF (3, 4);
66 
67 #ifdef DEBUG_FLAG
68 
69 #define DEBUG(format, ...) \
70   nemo_debug (DEBUG_FLAG, "%s: %s: " format, G_STRFUNC, G_STRLOC, \
71                   ##__VA_ARGS__)
72 
73 #define DEBUG_FILES(files, format, ...) \
74   nemo_debug_files (DEBUG_FLAG, files, "%s:" format, G_STRFUNC, \
75                         ##__VA_ARGS__)
76 
77 #define DEBUGGING nemo_debug_flag_is_set(DEBUG_FLAG)
78 
79 #endif /* DEBUG_FLAG */
80 
81 #else /* ENABLE_DEBUG */
82 
83 #ifdef DEBUG_FLAG
84 
85 #define DEBUG(format, ...) \
86   G_STMT_START { } G_STMT_END
87 
88 #define DEBUG_FILES(files, format, ...) \
89   G_STMT_START { } G_STMT_END
90 
91 #define DEBUGGING 0
92 
93 #endif /* DEBUG_FLAG */
94 
95 #endif /* ENABLE_DEBUG */
96 
97 G_END_DECLS
98 
99 #endif /* __NEMO_DEBUG_H__ */
100