Debian Codegraph @

pkcs11/gkm/gkm-debug.h

raw
1 /*
2 * Copyright (C) 2007 Nokia Corporation
3 * Copyright (C) 2007-2011 Collabora Ltd.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef GKM_DEBUG_H
21 #define GKM_DEBUG_H
22
23 #include "config.h"
24
25 #include "gkm-log.h"
26
27 #include <glib.h>
28
29 G_BEGIN_DECLS
30
31 /* Please keep this enum in sync with #keys in gcr-debug.c */
32 typedef enum {
33 GKM_DEBUG_STORAGE = 1 << 1,
34 GKM_DEBUG_OBJECT = 1 << 2,
35 } GkmDebugFlags;
36
37 gboolean gkm_debug_flag_is_set (GkmDebugFlags flag);
38
39 void gkm_debug_set_flags (const gchar *flags_string);
40
41 void gkm_debug_message (GkmDebugFlags flag,
42 const gchar *format,
43 ...) G_GNUC_PRINTF (2, 3);
44
45 G_END_DECLS
46
47 #endif /* GKM_DEBUG_H */
48
49 /* -----------------------------------------------------------------------------
50 * Below this point is outside the GKM_DEBUG_H guard - so it can take effect
51 * more than once. So you can do:
52 *
53 * #define DEBUG_FLAG GKM_DEBUG_ONE_THING
54 * #include "gcr-debug.h"
55 * ...
56 * DEBUG ("if we're debugging one thing");
57 * ...
58 * #undef DEBUG_FLAG
59 * #define DEBUG_FLAG GKM_DEBUG_OTHER_THING
60 * #include "gcr-debug.h"
61 * ...
62 * DEBUG ("if we're debugging the other thing");
63 * ...
64 */
65
66 #ifdef DEBUG_FLAG
67 #ifdef WITH_DEBUG
68
69 #undef gkm_debug
70 #define gkm_debug(format, ...) \
71 gkm_debug_message (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__)
72
73 #undef gkm_debugging
74 #define gkm_debugging \
75 gkm_debug_flag_is_set (DEBUG_FLAG)
76
77 #else /* !defined (WITH_DEBUG) */
78
79 #undef gkm_debug
80 #define gkm_debug(format, ...) \
81 do {} while (0)
82
83 #undef gkm_debugging
84 #define gkm_debugging 0
85
86 #endif /* !defined (WITH_DEBUG) */
87
88 #endif /* defined (DEBUG_FLAG) */