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