1 /* vi: set et sw=4 ts=8 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
3 /*
4 * This file is part of mission-control
5 *
6 * Copyright (C) 2007-2009 Nokia Corporation.
7 * Copyright (C) 2009 Collabora Ltd.
8 *
9 * Contact: Naba Kumar <naba.kumar@nokia.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * version 2.1 as published by the Free Software Foundation.
14 *
15 * This library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 * 02110-1301 USA
24 *
25 */
26
27 #ifndef __MCD_DEBUG_H__
28 #define __MCD_DEBUG_H__
29
30 #include <glib.h>
31 #include <glib-object.h>
32
33 G_BEGIN_DECLS
34
35 #undef DEBUG
36
37 #ifdef ENABLE_DEBUG
38
39 #define DEBUGGING (_mcd_debug_get_level () > 0)
40 #define DEBUG(format, ...) \
41 mcd_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
42 #define WARNING(format, ...) \
43 g_warning ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
44
45 #else /* !defined ENABLE_DEBUG */
46
47 #define DEBUGGING (0)
48 #define DEBUG(format, ...) do {} while (0)
49
50 #endif /* ENABLE_DEBUG */
51
52 #define MESSAGE(format, ...) \
53 g_message ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
54 #define WARNING(format, ...) \
55 g_warning ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
56 #define CRITICAL(format, ...) \
57 g_critical ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
58 #define ERROR(format, ...) \
59 g_error ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
60
61 extern gint mcd_debug_level;
62
63 void mcd_debug_init (void);
64
65 void mcd_debug_set_level (gint level);
_mcd_debug_get_level(void)66 static inline gint _mcd_debug_get_level (void)
67 {
68 return mcd_debug_level;
69 }
70
71 void mcd_debug_print_tree (gpointer obj);
72
73 void mcd_debug (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
74
75 G_END_DECLS
76
77 #endif /* __MCD_DEBUG_H__ */
78