On to our second kernel module! Here, we shall emit nine printk instances, one at each of the eight log levels, plus one via the pr_devel() macro (which is really nothing but the KERN_DEBUG log level). Let's check out the relevant code:
// ch4/printk_loglvl/printk_loglvl.c
static int __init printk_loglvl_init(void)
{
pr_emerg ("Hello, world @ log-level KERN_EMERG [0]\n");
pr_alert ("Hello, world @ log-level KERN_ALERT [1]\n");
pr_crit ("Hello, world @ log-level KERN_CRIT [2]\n");
pr_err ("Hello, world @ log-level KERN_ERR [3]\n");
pr_warn ("Hello, world @ log-level KERN_WARNING [4]\n");
pr_notice("Hello, world @ log-level KERN_NOTICE [5]\n");
pr_info ("Hello, world @ log-level KERN_INFO [6]\n");
pr_debug ("Hello, world @ log-level KERN_DEBUG [7]\n");
pr_devel("Hello, world via the pr_devel() macro"...