summaryrefslogtreecommitdiff
path: root/include/mailutils/debug.hm4
blob: bdcbcd0f964701dad359612cd61ccbc004534ac7 (plain)
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
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
/* GNU Mailutils -- a suite of utilities for electronic mail -*- c -*-
   Copyright (C) 1999, 2000, 2005, 2007 Free Software Foundation, Inc.

   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 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   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 Street, Fifth Floor,
   Boston, MA 02110-1301 USA */

#ifndef _MAILUTILS_DEBUG_H
#define _MAILUTILS_DEBUG_H

#include <stdarg.h>

#include <mailutils/types.h>

#define MU_DEBUG(d,l,s) MU_DEBUG1(d,l,"%s",s)

#ifdef __cplusplus
extern "C" {
#endif

#define MU_DEBUG_ERROR  0
#define MU_DEBUG_TRACE0 1
#define MU_DEBUG_TRACE MU_DEBUG_TRACE0
#define MU_DEBUG_TRACE1 2 
#define MU_DEBUG_TRACE2 3
#define MU_DEBUG_TRACE3 4
#define MU_DEBUG_TRACE4 5
#define MU_DEBUG_TRACE5 6
#define MU_DEBUG_TRACE6 7
#define MU_DEBUG_TRACE7 8 

#define MU_DEBUG_PROT   9

#define MU_DEBUG_LEVEL_MASK(lev) (1 << (lev))
#define MU_DEBUG_LEVEL_UPTO(lev) ((1 << ((lev)+1)) - 1)

#define MU_DEBUG_INHERIT    0xf0000
#define MU_DEBUG_EXTRACT_LEVEL(s) ((s) & ~MU_DEBUG_INHERIT)
  
int mu_debug_create    (mu_debug_t *, void *owner);
void mu_debug_destroy  (mu_debug_t *, void *owner);
void *mu_debug_get_owner (mu_debug_t);
int mu_debug_set_level (mu_debug_t, size_t level);
int mu_debug_get_level (mu_debug_t, size_t *plevel);
int mu_debug_print     (mu_debug_t debug, size_t level,
 		        const char *format, ...) MU_PRINTFLIKE(3,4);
int mu_debug_printv    (mu_debug_t debug, size_t level,
			const char *format, va_list ap);
int mu_debug_check_level (mu_debug_t debug, size_t level);

int mu_debug_printf (mu_debug_t debug, size_t level, const char *format, ...)
                        MU_PRINTFLIKE(3,4);
  
int mu_debug_vprintf (mu_debug_t debug, size_t level, const char *format,
                      va_list ap);

extern int mu_debug_line_info;
  
typedef int (*mu_debug_printer_fp) (mu_debug_t, size_t level, const char *buf);
  
extern int mu_debug_set_print (mu_debug_t,
			       mu_debug_printer_fp printer,
                               void *owner);
extern mu_debug_printer_fp mu_debug_default_printer;
  
int mu_debug_syslog_printer (mu_debug_t, size_t, const char *);
int mu_debug_stderr_printer (mu_debug_t, size_t, const char *);

unsigned mu_global_debug_level (const char *object_name);
int mu_global_debug_set_level (const char *object_name, unsigned level);
int mu_global_debug_clear_level (const char *object_name);
int mu_global_debug_from_string (const char *string, const char *errpfx);

forloop(`i',1,11,`MKDEBUG(i)')

#ifdef __cplusplus
}
#endif

#endif /* _MAILUTILS_DEBUG_H */

Return to:

Send suggestions and report system problems to the System administrator.