Example::
printk( KERN_ERR "Failed to register device %s with major %d\n", MOD_NAME, MAJOR);
It is possible to read and modify the console loglevel using the text file
/proc/sys/kernel/printk.
The file hosts four integer values:
- current loglevel,
- default level for messages that lack an explicit loglevel,
- minimum allowed loglevel
- the boot-time default loglevel.
# echo 8 > /proc/sys/kernel/printk
KERN_* parameters are defined in
include/linux/kernel.has follows:
Macro Name | Numeric Value | Description |
KERN_EMERG | 0 | Used for emergency messages, usually those that precede a crash. |
KERN_ALERT | 1 | A situation requiring immediate action. |
KERN_CRIT | 2 | Critical conditions, often related to serious hardware or software failures. |
KERN_ERR | 3 | Used to report error conditions; device drivers often use KERN_ERR to report hardware difficulties. |
KERN_WARNING | 4 | Warnings about problematic situations that do not, in themselves, create serious problems with the system. |
KERN_NOTICE | 5 | Situations that are normal, but still worthy of note. A number of security-related conditions are reported at this level. |
KERN_INFO | 6 | Informational messages. Many drivers print information about the hardware they find at startup time at this level. |
KERN_DEBUG | 7 | Used for debugging messages. |