summaryrefslogtreecommitdiff
path: root/debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'debug.h')
-rw-r--r--debug.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/debug.h b/debug.h
index e69de29..0c5e3a5 100644
--- a/debug.h
+++ b/debug.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * debug.h
+ *
+ * Thu Nov 1 13:38:47 CET 2012
+ * Copyright 2012 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Debug Module.
+ *
+ * Debug Module is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Debug Module is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Debug Module; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __DEBUG_MODULE_DEBUG_H__
+#define __DEBUG_MODULE_DEBUG_H__
+
+#include <stdio.h>
+
+void debug_init(FILE *fp);
+void debug_parse(const char *fmt);
+
+enum __debug_class
+{
+ __class_fixme = 0,
+ __class_err = 1,
+ __class_warn = 2,
+ __class_info = 3,
+ __class_debug = 4
+};
+
+int __debug(const char *func, const int line, enum __debug_class cl,
+ const char *ch, const char *fmt, ...)
+ __attribute__((format (printf,5,6)));
+
+#define __DEBUG_PRINT(cl, ch, fmt...) \
+ do { __debug(__func__, __LINE__, cl, ch, fmt); } while(0)
+#define __DEBUG(cl, ch, fmt...) \
+ __DEBUG_PRINT(__class##cl, #ch, fmt)
+
+#define ERR(ch, fmt...) __DEBUG(_err, ch, fmt)
+#define WARN(ch, fmt...) __DEBUG(_warn, ch, fmt)
+#define INFO(ch, fmt...) __DEBUG(_info, ch, fmt)
+#define DEBUG(ch, fmt...) __DEBUG(_debug, ch, fmt)
+
+#endif/*__DEBUG_MODULE_DEBUG_H__*/