1.PRINTK () is a log-logging mechanism for a kernel that is often used to record information or warnings. PRINTK can specify the priority of the output log, with the corresponding macro definition in the Include/linux/kern_levels.h
1 #defineKern_soh "\001"/* ASCII Start of Header */2 #defineKern_soh_ascii ' \001 '3 4 #defineKern_emerg Kern_soh "0"/* system is unusable */5 #defineKern_alert Kern_soh "1"/* action must be taken immediately * *6 #defineKern_crit Kern_soh "2"/* Critical conditions */7 #defineKern_err Kern_soh "3"/* ERROR conditions */8 #defineKern_warning Kern_soh "4"/* WARNING conditions */9 #defineKern_notice Kern_soh "5"/* Normal but significant condition */Ten #defineKern_info Kern_soh "6"/* Informational */ One #defineKern_debug Kern_soh "7"/* debug-level messages */ A - #defineKern_default Kern_soh "D"/* the DEFAULT kernel loglevel */ - the /* - * Annotation for a ' continued ' line of log printout - * line that had no enclosing \ n). Used by Core/arch code - * During early bootup (a continued line are not smp-safe otherwise). + */ - #defineKern_cont ""
If you do not specify a priority, this PRINTK uses the default priority, Default_message_loglevel is defined in LINUX-3.6.10/KERNEL/PRINTK.C
1 /* */ 2#define default_message_loglevel Config_default_message_loglevel 3 4 /* */ 5#define minimum_console_loglevel 1/* MINIMUM LOGLEVEL we let People use */ 6#define default_console_loglevel 7/* Anything more serious than kern_debug * *
If Config_default_message_loglevel is not configured, the default value is 4
DMESG: Analyzing the message generated by the core
DMESG |more//Output all the core information at boot time.
Intercept command: Cut grep
grep: Analyze a message, and if there is information we need, take it out.
1. View the current console's print level
1 cat/proc/sys/kernel/printk
4 4 1 7
Where the first "4" represents the print level of the kernel print function PRINTK, only information that is higher than his level can be printed on the console, with 0-3 levels of information
2. Modify the printing
echo "New print Level 4 1 7" > /PROC/SYS/KERNEL/PRINTK
3, insufficient printing level of information will be written to the log can be viewed through the dmesg command
4. PRINTK Print Level
1 #defineKern_emerg "<0>"/* system is unusable */2 #defineKern_alert "<1>"/* action must be taken immediately */3 #defineKern_crit "<2>"/* Critical conditions */4 #defineKern_err "<3>"/* ERROR conditions */5 #defineKern_warning "<4>"/* WARNING conditions */6 #defineKern_notice "<5>"/* Normal but significant condition * *7 #defineKern_info "<6>"/* Informational */8 #defineKern_debug "<7>"/* debug-level messages */
5, the use of PRINTK function
PRINTK ( print level "information to print")
Print level a few macros defined above
Linux kernel print level