1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib.h>
#include <stdio.h>
#include <debug.h>
static const char *resample_debug_level_names[] = {
"NONE",
"ERROR",
"WARNING",
"INFO",
"DEBUG",
"LOG"
};
static int resample_debug_level = RESAMPLE_LEVEL_LOG;
void
resample_debug_log (int level, const char *file, const char *function,
int line, const char *format, ...)
{
#ifndef GLIB_COMPAT
va_list varargs;
char *s;
if (level > resample_debug_level)
return;
va_start (varargs, format);
s = g_strdup_vprintf (format, varargs);
va_end (varargs);
fprintf (stderr, "RESAMPLE: %s: %s(%d): %s: %s\n",
resample_debug_level_names[level], file, line, function, s);
g_free (s);
#else
va_list varargs;
char s[1000];
if (level > resample_debug_level)
return;
va_start (varargs, format);
vsnprintf (s, 999, format, varargs);
va_end (varargs);
fprintf (stderr, "RESAMPLE: %s: %s(%d): %s: %s\n",
resample_debug_level_names[level], file, line, function, s);
#endif
}
void
resample_debug_set_level (int level)
{
resample_debug_level = level;
}
int
resample_debug_get_level (void)
{
return resample_debug_level;
}
|