first public release of samba4 code
[samba.git] / source4 / include / debug.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Samba debug defines
4    Copyright (C) Andrew Tridgell 2003
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program 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
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 /* the debug operations structure - contains function pointers to 
22    various debug implementations of each operation */
23 struct debug_ops {
24         /* function to log (using DEBUG) suspicious usage of data structure */
25         void (*log_suspicious_usage)(const char* from, const char* info);
26                                 
27         /* function to log (using printf) suspicious usage of data structure.
28          * To be used in circumstances when using DEBUG would cause loop. */
29         void (*print_suspicious_usage)(const char* from, const char* info);
30         
31         /* function to return process/thread id */
32         uint32 (*get_task_id)(void);
33 };
34
35 void do_debug(const char *, ...) PRINTF_ATTRIBUTE(1,2);
36
37 extern int DEBUGLEVEL;
38
39 #define DEBUGLVL(level) ((level) <= DEBUGLEVEL)
40 #define DEBUG(level, body) do { if (DEBUGLVL(level)) do_debug body; } while (0)
41 #define DEBUGADD(level, body) DEBUG(level, body)
42 #define DEBUGC(class, level, body) DEBUG(level, body)
43 #define DEBUGADDC(class, level, body) DEBUG(level, body)
44 #define DEBUGTAB(n) do_debug_tab(n)
45
46 enum debug_logtype {DEBUG_FILE, DEBUG_STDOUT, DEBUG_STDERR};
47
48 /* keep some debug class defines for now to avoid changing old code too much */
49 #define DBGC_AUTH 0