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 ev_set_debug(struct tevent_context *ev,
34 void (*debug)(void *context, enum ev_debug_level level,
35 const char *fmt, va_list ap),
38 ev->debug_ops.debug = debug;
39 ev->debug_ops.context = context;
44 debug function for ev_set_debug_stderr
46 void ev_debug_stderr(void *context, enum ev_debug_level level,
47 const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
48 void ev_debug_stderr(void *context, enum ev_debug_level level,
49 const char *fmt, va_list ap)
51 if (level <= EV_DEBUG_WARNING) {
52 vfprintf(stderr, fmt, ap);
57 convenience function to setup debug messages on stderr
58 messages of level EV_DEBUG_WARNING and higher are printed
60 int ev_set_debug_stderr(struct tevent_context *ev)
62 return ev_set_debug(ev, ev_debug_stderr, ev);
68 * The default debug action is to ignore debugging messages.
69 * This is the most appropriate action for a library.
70 * Applications using the library must decide where to
71 * redirect debugging messages
73 void ev_debug(struct tevent_context *ev, enum ev_debug_level level, const char *fmt, ...)
76 if (ev->debug_ops.debug == NULL) {
80 ev->debug_ops.debug(ev->debug_ops.context, level, fmt, ap);