2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 2005
5 Copyright (C) Jelmer Vernooij 2005
7 ** NOTE! The following LGPL license applies to the tevent
8 ** library. This does NOT imply that all of Samba is released
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 3 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, see <http://www.gnu.org/licenses/>.
25 #include <ccan/tevent/tevent.h>
26 #include <ccan/tevent/tevent_internal.h>
28 /********************************************************************
29 * Debug wrapper functions, modeled (with lot's of code copied as is)
30 * after the ev debug wrapper functions
31 ********************************************************************/
34 this allows the user to choose their own debug function
36 int tevent_set_debug(struct tevent_context *ev,
37 void (*debug)(void *context,
38 enum tevent_debug_level level,
40 va_list ap) PRINTF_FMT(3,0),
43 ev->debug_ops.debug = debug;
44 ev->debug_ops.context = context;
49 debug function for ev_set_debug_stderr
51 static void tevent_debug_stderr(void *private_data,
52 enum tevent_debug_level level,
54 va_list ap) PRINTF_FMT(3,0);
55 static void tevent_debug_stderr(void *private_data,
56 enum tevent_debug_level level,
57 const char *fmt, va_list ap)
59 if (level <= TEVENT_DEBUG_WARNING) {
60 vfprintf(stderr, fmt, ap);
65 convenience function to setup debug messages on stderr
66 messages of level TEVENT_DEBUG_WARNING and higher are printed
68 int tevent_set_debug_stderr(struct tevent_context *ev)
70 return tevent_set_debug(ev, tevent_debug_stderr, ev);
76 * The default debug action is to ignore debugging messages.
77 * This is the most appropriate action for a library.
78 * Applications using the library must decide where to
79 * redirect debugging messages
81 void tevent_debug(struct tevent_context *ev, enum tevent_debug_level level,
88 if (ev->debug_ops.debug == NULL) {
92 ev->debug_ops.debug(ev->debug_ops.context, level, fmt, ap);