29 lines
792 B
Markdown
29 lines
792 B
Markdown
|
# printk 说明
|
||
|
|
||
|
## 头文件
|
||
|
|
||
|
```cpp
|
||
|
#include <linux/kernel.h>
|
||
|
```
|
||
|
|
||
|
## 函数原型
|
||
|
|
||
|
```cpp
|
||
|
int printk(const char *fmt, ...);
|
||
|
```
|
||
|
|
||
|
## 参数说明
|
||
|
|
||
|
在 fmt 字符串前面增加以下宏可以控制 printk 的输出级别,数值越小打印级别越高。当设置的级别地于当前打印级别时,打印信息将不被输出。
|
||
|
|
||
|
```cpp
|
||
|
#define KERN_EMERG "<0>" /* system is unusable */
|
||
|
#define KERN_ALERT "<1>" /* action must be taken immediately */
|
||
|
#define KERN_CRIT "<2>" /* critical conditions */
|
||
|
#define KERN_ERR "<3>" /* error conditions */
|
||
|
#define KERN_WARNING "<4>" /* warning conditions */
|
||
|
#define KERN_NOTICE "<5>" /* normal but significant condition */
|
||
|
#define KERN_INFO "<6>" /* informational */
|
||
|
#define KERN_DEBUG
|
||
|
```
|