qemu-e2k/slirp/debug.h
Marc-André Lureau 226ea7a964 slirp: call into g_debug() for DEBUG macros
Make slirp use GLib logging, instead of fprintf(), so that
applications can filter log, process it etc.

With recent versions of glib, G_MESSAGES_DEBUG must be set to "all" or
"Slirp" to see slirp debug messages.

Reformat DEBUG_MISC & DEBUG_ERROR calls to not need \n ending.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2019-01-14 23:36:38 +01:00

42 lines
1.1 KiB
C

/*
* Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/
#ifndef DEBUG_H_
#define DEBUG_H_
#define DBG_CALL 0x1
#define DBG_MISC 0x2
#define DBG_ERROR 0x4
extern int slirp_debug;
#define DEBUG_CALL(fmt, ...) do { \
if (slirp_debug & DBG_CALL) { \
g_debug(fmt "...", ##__VA_ARGS__); \
} \
} while (0)
#define DEBUG_ARG(fmt, ...) do { \
if (slirp_debug & DBG_CALL) { \
g_debug(" " fmt, ##__VA_ARGS__); \
} \
} while (0)
#define DEBUG_MISC(fmt, ...) do { \
if (slirp_debug & DBG_MISC) { \
g_debug(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define DEBUG_ERROR(fmt, ...) do { \
if (slirp_debug & DBG_ERROR) { \
g_debug(fmt, ##__VA_ARGS__); \
} \
} while (0)
#endif /* DEBUG_H_ */