I wrote a hello word module that performs a printk when it is loaded in level ALERT and another printk when it is released with level INFO:
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("GPL");
static int init_hello(void)
{
printk(KERN_ALERT "init called in hello\n");
return 0;
}
static void cleanup_hello(void)
{
printk(KERN_INFO "cleanup called in hello\n");
}
module_init(init_hello);
module_exit(cleanup_hello);
Then I was trying to filter the kernel messages by its level, I did that using dmesg -l , but I want to see the messages as they appear, so I was using
tail -f /var/log/kern.log
Using this command I can see the messages, but how can I filter the messages by level?
I am using Ubuntu 14.04 with kernel 3.16.4
I then tried to print the messages to the console using:
echo 7 7 7 7 > /proc/sys/kernel/printk
But it doesn't print any message to the console. I tried to set the console-level using dmesg -n alert, but it doesn't work either, thus I am not sure what setting the console-level by dmesg or /proc/sys/kernel/printk does.
How can I use these levels efficiently?
Thanks for your help
/proc
are device pointers and setters. They are not files. Welcome!!!