2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 2003
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.
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.
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.
21 /* If we have these macros, we can add additional info to the header. */
23 #ifdef HAVE_FUNCTION_MACRO
24 #define FUNCTION_MACRO (__FUNCTION__)
26 #define FUNCTION_MACRO ("")
29 /* the debug operations structure - contains function pointers to
30 various debug implementations of each operation */
32 /* function to log (using DEBUG) suspicious usage of data structure */
33 void (*log_suspicious_usage)(const char* from, const char* info);
35 /* function to log (using printf) suspicious usage of data structure.
36 * To be used in circumstances when using DEBUG would cause loop. */
37 void (*print_suspicious_usage)(const char* from, const char* info);
39 /* function to return process/thread id */
40 uint32_t (*get_task_id)(void);
42 /* function to log process/thread id */
43 void (*log_task_id)(int fd);
46 void do_debug_header(int level, const char *location, const char *func);
47 void do_debug(const char *, ...) PRINTF_ATTRIBUTE(1,2);
49 extern int DEBUGLEVEL;
51 #define DEBUGLVL(level) ((level) <= DEBUGLEVEL)
52 #define _DEBUG(level, body, header) do { \
53 if (DEBUGLVL(level)) { \
55 do_debug_header(level, __location__, FUNCTION_MACRO); \
60 #define DEBUG(level, body) _DEBUG(level, body, True)
61 #define DEBUGADD(level, body) _DEBUG(level, body, False)
62 #define DEBUGC(class, level, body) DEBUG(level, body)
63 #define DEBUGADDC(class, level, body) DEBUGADD(level, body)
64 #define DEBUGTAB(n) do_debug_tab(n)
66 enum debug_logtype {DEBUG_STDOUT = 0, DEBUG_FILE = 1, DEBUG_STDERR = 2};