diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-10-23 15:35:10 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-10-23 15:35:10 +0200 |
commit | 8098a6dd71c42c5276846cd5da8314e0f248b7ce (patch) | |
tree | a952d73fa8142e4e3ffa2c9bab9c8ee8d78dc45f /debug.h |
This is the source code for an ActiveX plugin used to bridge
the oVirt portal with remote-viewer.
Diffstat (limited to 'debug.h')
-rw-r--r-- | debug.h | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -0,0 +1,55 @@ +/* + * Copyright 2013 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the GNU General Public License, version 2 or any + * later version. See the file COPYING in the top-level directory of + * this distribution or http://www.gnu.org/licenses/gpl-2.0.txt. + */ +#ifndef __DEBUG_H__
+#define __DEBUG_H__
+
+void spicex_log(unsigned int type, const char *function, const char *format, ...);
+void spicex_init_logger(void);
+void spicex_log_cleanup(void);
+
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
+
+#define ON_PANIC() ::abort()
+
+#ifdef SPICEX_DEBUG
+
+#define ASSERTBREAK DebugBreak()
+
+#define ASSERT(x) if (!(x)) { \
+ printf("%s: ASSERT %s failed\n", __FUNCTION__, #x); \
+ ASSERTBREAK; \
+}
+
+#else
+
+#define ASSERT(cond)
+
+#endif
+
+enum {
+ LOG_FATAL = 1,
+ LOG_ERROR,
+ LOG_WARN,
+ LOG_INFO,
+ LOG_DEBUG,
+};
+
+#define LOG(type, format, ...) spicex_log(type, __FUNCTION__, format, ## __VA_ARGS__)
+
+#define LOG_INFO(format, ...) LOG(LOG_INFO, format, ## __VA_ARGS__)
+#define LOG_WARN(format, ...) LOG(LOG_WARN, format, ## __VA_ARGS__)
+#define LOG_ERROR(format, ...) LOG(LOG_ERROR, format, ## __VA_ARGS__)
+
+#define DBG(level, format, ...) \
+ LOG(LOG_DEBUG + level, format, ## __VA_ARGS__) +
+
+
+#endif // __DEBUG_H__
|