printk is a C function from the Linux kernel interface that prints messages to the kernel log.[1] 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.[1] The string is then printed to the kernel log.[1]
It provides a printf-like
abstraction and its parsing of the format string and arguments behave similarly to printf
.[1] It acts as a debugging tool for kernel programmers who need this function for logging messages from the kernel.[1]
The printk
function prototype is:
int printk(const char *fmt, ...);
C standard library and its printf
function are unavailable in kernel mode, hence the need for printk
.[2]