xref: /DragonOS/kernel/src/common/kprint.h (revision 5b59005f930266d0e9c0092373e894826150f862)
1 /**
2  * @file kprint.h
3  * @author longjin
4  * @brief 内核日志打印程序
5  * @date 2022-01-28
6  *
7  * @copyright Copyright (c) 2022 longjin
8  *
9  */
10 
11 #pragma once
12 #include "printk.h"
13 
14 #define ksuccess(...)                          \
15     do                                         \
16     {                                          \
17         printk("[ ");                          \
18         printk_color(GREEN, BLACK, "SUCCESS"); \
19         printk(" ] ");                         \
20         printk(__VA_ARGS__);                   \
21         printk("\n");                          \
22     } while (0)
23 
24 #define kinfo(...)           \
25     do                       \
26     {                        \
27         printk("[ INFO ] "); \
28         printk(__VA_ARGS__); \
29         printk("\n");        \
30     } while (0)
31 
32 #define kdebug(...)                                        \
33     do                                                     \
34     {                                                      \
35         printk("[ DEBUG ] (%s:%d)\t", __FILE__, __LINE__); \
36         printk(__VA_ARGS__);                               \
37         printk("\n");                                      \
38     } while (0)
39 
40 #define kwarn(...)                                 \
41     do                                             \
42     {                                              \
43         printk("[ ");                              \
44         printk_color(YELLOW, BLACK, "WARN");       \
45         printk(" ] "); \
46         printk(__VA_ARGS__);                       \
47         printk("\n");                              \
48     } while (0)
49 
50 #define kerror(...)                        \
51     do                                     \
52     {                                      \
53         printk("[ ");                      \
54         printk_color(RED, BLACK, "ERROR"); \
55         printk(" ] ");                     \
56         printk(__VA_ARGS__);               \
57         printk("\n");                      \
58     } while (0)
59 
60 #define kterminated(...)                        \
61     do                                          \
62     {                                           \
63         printk("[ ");                           \
64         printk_color(RED, BLACK, "TERMINATED"); \
65         printk(" ] ");                          \
66         printk(__VA_ARGS__);                    \
67         printk("\n");                           \
68     } while (0)
69 
70 #define kBUG(...)                                   \
71     do                                              \
72     {                                               \
73         printk("[ ");                               \
74         printk_color(RED, BLACK, "BUG");            \
75         printk(" ] (%s:%d)\t", __FILE__, __LINE__); \
76         printk(__VA_ARGS__);                        \
77         printk("\n");                               \
78     } while (0)
79