2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 2005
5 Copyright (C) Jelmer Vernooij 2005
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "tevent_internal.h"
25 /********************************************************************
26 * Debug wrapper functions, modeled (with lot's of code copied as is)
27 * after the ev debug wrapper functions
28 ********************************************************************/
31 this allows the user to choose their own debug function
33 int tevent_set_debug(struct tevent_context *ev,
34 void (*debug)(void *context,
35 enum tevent_debug_level level,
37 va_list ap) PRINTF_ATTRIBUTE(3,0),
40 ev->debug_ops.debug = debug;
41 ev->debug_ops.context = context;
46 debug function for ev_set_debug_stderr
48 static void tevent_debug_stderr(void *private_data,
49 enum tevent_debug_level level,
51 va_list ap) PRINTF_ATTRIBUTE(3,0);
52 static void tevent_debug_stderr(void *private_data,
53 enum tevent_debug_level level,
54 const char *fmt, va_list ap)
56 if (level <= TEVENT_DEBUG_WARNING) {
57 vfprintf(stderr, fmt, ap);
62 convenience function to setup debug messages on stderr
63 messages of level TEVENT_DEBUG_WARNING and higher are printed
65 int tevent_set_debug_stderr(struct tevent_context *ev)
67 return tevent_set_debug(ev, tevent_debug_stderr, ev);
73 * The default debug action is to ignore debugging messages.
74 * This is the most appropriate action for a library.
75 * Applications using the library must decide where to
76 * redirect debugging messages
78 void tevent_debug(struct tevent_context *ev, enum tevent_debug_level level,
85 if (ev->debug_ops.debug == NULL) {
89 ev->debug_ops.debug(ev->debug_ops.context, level, fmt, ap);