What's the exact difference between printk
and pr_info
functions ? And under what conditions, should I choose one over the another ?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With