内核中打印函数的使用
- printk(打印级别 “格式化输出”,...);
- printk(“格式化输出”,...);
打印级别:
#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 "<7>" /* debug-level messages */
<0> ------------------ <7>
优先级最高 优先级最低的
查看控制台的打印级别:
$cat /proc/sys/kernel/printk
4 4 1 7
第一个字段(4): 打印台的消息级别
第二个字段(4): 默认消息级别 printk(“格式化输出”,...);
第三个字段(1): 最高打印级别
第四个字段(7): 最低打印级别
当消息级别大于终端级别时消息才可以显示
修改方法:
echo “7 7 1 7” > /proc/sys/kernel/printk