Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between printk and pr_info

What's the exact difference between printk and pr_info functions ? And under what conditions, should I choose one over the another ?

like image 319
Jarvis Avatar asked Feb 15 '17 07:02

Jarvis


People also ask

What is printk in Linux kernel?

printk is a C function from the Linux kernel interface that prints messages to the kernel log. It accepts a string parameter called the format string, which specifies a method for rendering an arbitrary number of varied data type parameter(s) into a string. The string is then printed to the kernel log.

Where does printk go?

All printk() messages are printed to the kernel log buffer, which is a ring buffer exported to userspace through /dev/kmsg. The usual way to read it is using dmesg . The log level specifies the importance of a message.

What is Kern_info?

Loglevel 6 it's KERN_INFO : this is the log level used for informational messages about the action performed by the kernel. Finally, we have KERN_DEBUG , or loglevel 7 , which is mainly used for debugging.


1 Answers

The kernel's printk.h has:

#define pr_info(fmt,arg...) \     printk(KERN_INFO fmt,##arg) 

Just like the name, pr_info is printk with the KERN_INFO priority.

like image 77
jacob Avatar answered Sep 18 '22 22:09

jacob