summaryrefslogtreecommitdiff
path: root/debug
diff options
context:
space:
mode:
authordianshi <dianshi@main.lv>2020-04-05 11:41:04 +0100
committerdianshi <dianshi@main.lv>2020-04-05 11:41:04 +0100
commit051cea0b4bf3bdffb7db025124b2b4757d8a1b31 (patch)
treebbddbd463ed4c81bcababa1e83da14d803f25767 /debug
parentee81e9f51d1406c1591de0cae620552880f326f7 (diff)
downloaddwm-pixel-051cea0b4bf3bdffb7db025124b2b4757d8a1b31.tar.gz
dwm-pixel-051cea0b4bf3bdffb7db025124b2b4757d8a1b31.zip
Initial non moded with all souces added
Diffstat (limited to 'debug')
-rw-r--r--debug/Kconfig24
-rw-r--r--debug/debug.h66
2 files changed, 90 insertions, 0 deletions
diff --git a/debug/Kconfig b/debug/Kconfig
new file mode 100644
index 0000000..21dae6d
--- /dev/null
+++ b/debug/Kconfig
@@ -0,0 +1,24 @@
+menuconfig DEBUG
+ bool "Enable debug output"
+ option debug
+
+if DEBUG
+config DEBUG_PRINT_DEBUG
+ bool "Print debug"
+ default y
+
+config DEBUG_COLORIZE
+ bool "Colorize output"
+ default n
+ depends on DEBUG_PRINT_DEBUG
+
+config DEBUG_PRINT_LINENUM
+ bool "Print line number in debug"
+ default n
+ depends on DEBUG_PRINT_DEBUG
+
+config DEBUG_PRINT_FILENAME
+ bool "Print file name in debug"
+ default n
+ depends on DEBUG_PRINT_DEBUG
+endif
diff --git a/debug/debug.h b/debug/debug.h
new file mode 100644
index 0000000..b030fbe
--- /dev/null
+++ b/debug/debug.h
@@ -0,0 +1,66 @@
+#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 CONFIG_DEBUG_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 CONFIG_DEBUG_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 CONFIG_DEBUG_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 CONFIG_DEBUG_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);
+
+
+#endif