~ubuntu-branches/debian/squeeze/libnice/squeeze

« back to all changes in this revision

Viewing changes to agent/debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2009-01-04 17:45:34 UTC
  • Revision ID: james.westby@ubuntu.com-20090104174534-dh5u1pfonumqa99c
Tags: upstream-0.0.4
ImportĀ upstreamĀ versionĀ 0.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the Nice GLib ICE library.
 
3
 *
 
4
 * (C) 2008 Collabora Ltd.
 
5
 * (C) 2008 Nokia Corporation. All rights reserved.
 
6
 *
 
7
 * The contents of this file are subject to the Mozilla Public License Version
 
8
 * 1.1 (the "License"); you may not use this file except in compliance with
 
9
 * the License. You may obtain a copy of the License at
 
10
 * http://www.mozilla.org/MPL/
 
11
 *
 
12
 * Software distributed under the License is distributed on an "AS IS" basis,
 
13
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
14
 * for the specific language governing rights and limitations under the
 
15
 * License.
 
16
 *
 
17
 * The Original Code is the Nice GLib ICE library.
 
18
 *
 
19
 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
 
20
 * Corporation. All Rights Reserved.
 
21
 *
 
22
 * Contributors:
 
23
 *   Youness Alaoui, Collabora Ltd.
 
24
 *
 
25
 * Alternatively, the contents of this file may be used under the terms of the
 
26
 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
 
27
 * case the provisions of LGPL are applicable instead of those above. If you
 
28
 * wish to allow use of your version of this file only under the terms of the
 
29
 * LGPL and not to allow others to use your version of this file under the
 
30
 * MPL, indicate your decision by deleting the provisions above and replace
 
31
 * them with the notice and other provisions required by the LGPL. If you do
 
32
 * not delete the provisions above, a recipient may use your version of this
 
33
 * file under either the MPL or the LGPL.
 
34
 */
 
35
 
 
36
#ifdef HAVE_CONFIG_H
 
37
# include <config.h>
 
38
#endif
 
39
 
 
40
#include "debug.h"
 
41
 
 
42
#include "stunagent.h"
 
43
 
 
44
 
 
45
static int debug_enabled = 0;
 
46
 
 
47
#define NICE_DEBUG_STUN 1
 
48
#define NICE_DEBUG_NICE 2
 
49
 
 
50
static const GDebugKey keys[] = {
 
51
  { (gchar *)"stun",  NICE_DEBUG_STUN },
 
52
  { (gchar *)"nice",  NICE_DEBUG_NICE },
 
53
  { NULL, 0},
 
54
};
 
55
 
 
56
 
 
57
void nice_debug_init ()
 
58
{
 
59
  const gchar *flags_string;
 
60
  guint flags;
 
61
 
 
62
  flags_string = g_getenv ("NICE_DEBUG");
 
63
 
 
64
  nice_debug_disable (TRUE);
 
65
 
 
66
  if (flags_string != NULL) {
 
67
    flags = g_parse_debug_string (flags_string, keys,  2);
 
68
 
 
69
    if (flags & NICE_DEBUG_NICE)
 
70
      nice_debug_enable (FALSE);
 
71
    if (flags & NICE_DEBUG_STUN)
 
72
      stun_debug_enable ();
 
73
 
 
74
  }
 
75
}
 
76
 
 
77
void nice_debug_enable (gboolean with_stun)
 
78
{
 
79
  debug_enabled = 1;
 
80
  if (with_stun)
 
81
    stun_debug_enable ();
 
82
}
 
83
void nice_debug_disable (gboolean with_stun)
 
84
{
 
85
  debug_enabled = 0;
 
86
  if (with_stun)
 
87
    stun_debug_disable ();
 
88
}
 
89
 
 
90
void nice_debug (const char *fmt, ...)
 
91
{
 
92
  va_list ap;
 
93
  if (debug_enabled) {
 
94
    va_start (ap, fmt);
 
95
    g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, fmt, ap);
 
96
    va_end (ap);
 
97
  }
 
98
}