empathy-debug.h 2.87 KB
Newer Older
1
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
2
/*
3 4
 * Copyright (C) 2007 Collabora Ltd.
 * Copyright (C) 2007 Nokia Corporation
5
 *
6 7 8 9
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * 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 13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16 17 18
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 20
 */

21 22
#ifndef __EMPATHY_DEBUG_H__
#define __EMPATHY_DEBUG_H__
23

24 25 26
#include "config.h"


27
#include <glib.h>
28
#include <telepathy-glib/debug.h>
29 30 31

G_BEGIN_DECLS

32 33 34 35 36 37 38 39
/* Please keep this enum in sync with #keys in empathy-debug.c */
typedef enum
{
  EMPATHY_DEBUG_TP = 1 << 1,
  EMPATHY_DEBUG_CHAT = 1 << 2,
  EMPATHY_DEBUG_CONTACT = 1 << 3,
  EMPATHY_DEBUG_ACCOUNT = 1 << 4,
  EMPATHY_DEBUG_IRC = 1 << 5,
40
  EMPATHY_DEBUG_DISPATCHER = 1 << 6,
41
  EMPATHY_DEBUG_FT = 1 << 7,
42 43
  EMPATHY_DEBUG_LOCATION = 1 << 8,
  EMPATHY_DEBUG_OTHER = 1 << 9,
44
  EMPATHY_DEBUG_SHARE_DESKTOP = 1 << 10,
45
  EMPATHY_DEBUG_CONNECTIVITY = 1 << 11,
46
  EMPATHY_DEBUG_IMPORT_MC4_ACCOUNTS = 1 << 11,
Xavier Claessens's avatar
Xavier Claessens committed
47
  EMPATHY_DEBUG_TESTS = 1 << 12,
48
  EMPATHY_DEBUG_VOIP = 1 << 13,
Cosimo Cecchi's avatar
Cosimo Cecchi committed
49
  EMPATHY_DEBUG_TLS = 1 << 14,
50
  EMPATHY_DEBUG_SASL = 1 << 15,
51
} EmpathyDebugFlags;
52

53 54 55
gboolean empathy_debug_flag_is_set (EmpathyDebugFlags flag);
void empathy_debug (EmpathyDebugFlags flag, const gchar *format, ...)
    G_GNUC_PRINTF (2, 3);
56
void empathy_debug_free (void);
57
void empathy_debug_set_flags (const gchar *flags_string);
58 59
G_END_DECLS

60
#endif /* __EMPATHY_DEBUG_H__ */
61

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
/* ------------------------------------ */

/* Below this point is outside the __DEBUG_H__ guard - so it can take effect
 * more than once. So you can do:
 *
 * #define DEBUG_FLAG EMPATHY_DEBUG_ONE_THING
 * #include "internal-debug.h"
 * ...
 * DEBUG ("if we're debugging one thing");
 * ...
 * #undef DEBUG_FLAG
 * #define DEBUG_FLAG EMPATHY_DEBUG_OTHER_THING
 * #include "internal-debug.h"
 * ...
 * DEBUG ("if we're debugging the other thing");
 * ...
 */

#ifdef DEBUG_FLAG
#ifdef ENABLE_DEBUG

#undef DEBUG
#define DEBUG(format, ...) \
  empathy_debug (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__)

#undef DEBUGGING
#define DEBUGGING empathy_debug_flag_is_set (DEBUG_FLAG)

#else /* !defined (ENABLE_DEBUG) */

#undef DEBUG
#define DEBUG(format, ...) do {} while (0)

#undef DEBUGGING
#define DEBUGGING 0

#endif /* !defined (ENABLE_DEBUG) */
99 100 101

#define gabble_debug_free() G_STMT_START { } G_STMT_END

102
#endif /* defined (DEBUG_FLAG) */