Second Extended Filesystem (ext2) and other improvements (#33)
[lunaix-os.git] / lunaix-os / includes / lunaix / syslog.h
index 24233159bc608de5a5ebc57db45e18e2e893d146..3b827f678e409dc1249ce2c4ab9d8f9ef40d012c 100644 (file)
@@ -2,6 +2,7 @@
 #define __LUNAIX_SYSLOG_H
 
 #include <lunaix/compiler.h>
+#include <lunaix/spike.h>
 #include <stdarg.h>
 
 #define KLOG_DEBUG 0
 #define KLOG_ERROR 3
 #define KLOG_FATAL 4
 
-#define _LEVEL_INFO "0"
-#define _LEVEL_WARN "1"
-#define _LEVEL_ERROR "2"
-#define _LEVEL_DEBUG "3"
-
 #define KMSG_LVLSTART '\x1b'
 #define KMSG_LOGLEVEL(c) ((c) - '0')
 
     {                                                                          \
         va_list args;                                                          \
         va_start(args, fmt);                                                   \
-        __kprintf(module, fmt, args);                                          \
+        kprintf_m(module, fmt, args);                                          \
         va_end(args);                                                          \
     }
 
+#define printk(fmt, ...) kprintf_v(__FILE__, fmt, ##__VA_ARGS__)
+
+#define DEBUG(fmt, ...) kprintf(KDEBUG fmt, ##__VA_ARGS__)
+#define INFO(fmt, ...) kprintf(KINFO fmt, ##__VA_ARGS__)
+#define WARN(fmt, ...) kprintf(KWARN fmt, ##__VA_ARGS__)
+#define ERROR(fmt, ...) kprintf(KERROR fmt, ##__VA_ARGS__)
+#define FATAL(fmt, ...)                                                        \
+    ({                                                                         \
+        kprintf(KFATAL fmt, ##__VA_ARGS__);                                    \
+        fail(fmt);                                                             \
+    })
+
 void
-__kprintf(const char* component, const char* fmt, va_list args);
+kprintf_m(const char* component, const char* fmt, va_list args);
 
+void
+kprintf_v(const char* component, const char* fmt, ...);
 #endif /* __LUNAIX_SYSLOG_H */