summaryrefslogtreecommitdiff
path: root/libcmd/debug.h
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2016-05-10 22:42:11 +0100
committerFreeArtMan <dos21h@gmail.com>2016-05-10 22:42:11 +0100
commit44dedb90f005bb0de9bddbd592a5c78f28bc67d1 (patch)
tree274b9cea44df3f96a965c564e26cdac42d3af94f /libcmd/debug.h
parentbb426577c85f6d97cc28ab677e98e2b1f73eadac (diff)
downloadihe-44dedb90f005bb0de9bddbd592a5c78f28bc67d1.tar.gz
ihe-44dedb90f005bb0de9bddbd592a5c78f28bc67d1.zip
Replace cmd first part
Diffstat (limited to 'libcmd/debug.h')
-rw-r--r--libcmd/debug.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/libcmd/debug.h b/libcmd/debug.h
new file mode 100644
index 0000000..a8bf211
--- /dev/null
+++ b/libcmd/debug.h
@@ -0,0 +1,69 @@
+#ifndef __RB_DEBUG_UTILS_H
+#define __RB_DEBUG_UTILS_H
+
+//what about kprintf?
+
+//config options
+#define PRINTF printf
+#define COLORIZE
+#define PRINT_LINENUM
+#define PRINT_FILENAME
+#define PRINT_DEBUG
+
+
+//use color
+#ifdef COLORIZE
+ #define D_COLOR "1;32m"
+ #define D_COLOR_S "\033[" D_COLOR
+ #define D_COLOR_E "\033[0m"
+ #define E_COLOR "1;31m"
+ #define E_COLOR_S "\033[" E_COLOR
+ #define E_COLOR_E "\033[0m"
+#else
+ #define D_COLOR
+ #define D_COLOR_S
+ #define D_COLOR_E
+ #define E_COLOR
+ #define E_COLOR_S
+ #define E_COLOR_E
+#endif
+
+//print debug line
+#ifdef PRINT_LINENUM
+ #define PRINT_LINE_F "LINE:%d "
+ #define PRINT_LINE_D __LINE__
+#else
+ #define PRINT_LINE_F ""
+ #define PRINT_LINE_D ""
+#endif
+
+//print
+#ifdef PRINT_FILENAME
+ #define PRINT_FILE_F "FILE:%s "
+ #define PRINT_FILE_D __FILE__
+#else
+ #define PRINT_FILE_F ""
+ #define PRINT_FILE_D ""
+#endif
+
+//print debug string
+#ifdef PRINT_DEBUG
+ #define PRINT_DEBUG_F "Debug: "
+#else
+ #define PRINT_DEBUG_F ""
+#endif
+
+#define PRINT( format, args ... ) PRINTF( D_COLOR_S PRINT_DEBUG_F \
+ PRINT_FILE_F PRINT_LINE_F format D_COLOR_E, PRINT_FILE_D, \
+ PRINT_LINE_D, ##args);
+
+#define ERROR( format, args ... ) PRINTF( E_COLOR_S PRINT_DEBUG_F \
+ PRINT_FILE_F PRINT_LINE_F format E_COLOR_E, PRINT_FILE_D, \
+ PRINT_LINE_D, ##args);
+
+#define PNL() PRINT("\n");
+
+#define ENL() ERROR("\n");
+
+
+#endif