~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/core-api/printk-basics.rst

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/core-api/printk-basics.rst (Version linux-6.11.5) and /Documentation/core-api/printk-basics.rst (Version linux-5.6.19)


  1 .. SPDX-License-Identifier: GPL-2.0               
  2                                                   
  3 ===========================                       
  4 Message logging with printk                       
  5 ===========================                       
  6                                                   
  7 printk() is one of the most widely known funct    
  8 standard tool we have for printing messages an    
  9 tracing and debugging. If you're familiar with    
 10 is based on it, although it has some functiona    
 11                                                   
 12   - printk() messages can specify a log level.    
 13                                                   
 14   - the format string, while largely compatibl    
 15     exact same specification. It has some exte    
 16     (no ``%n`` or floating point conversion sp    
 17     printk format specifiers right <printk-spe    
 18                                                   
 19 All printk() messages are printed to the kerne    
 20 buffer exported to userspace through /dev/kmsg    
 21 using ``dmesg``.                                  
 22                                                   
 23 printk() is typically used like this::            
 24                                                   
 25   printk(KERN_INFO "Message: %s\n", arg);         
 26                                                   
 27 where ``KERN_INFO`` is the log level (note tha    
 28 string, the log level is not a separate argume    
 29                                                   
 30 +----------------+--------+-------------------    
 31 | Name           | String |  Alias function       
 32 +================+========+===================    
 33 | KERN_EMERG     | "0"    | pr_emerg()            
 34 +----------------+--------+-------------------    
 35 | KERN_ALERT     | "1"    | pr_alert()            
 36 +----------------+--------+-------------------    
 37 | KERN_CRIT      | "2"    | pr_crit()             
 38 +----------------+--------+-------------------    
 39 | KERN_ERR       | "3"    | pr_err()              
 40 +----------------+--------+-------------------    
 41 | KERN_WARNING   | "4"    | pr_warn()             
 42 +----------------+--------+-------------------    
 43 | KERN_NOTICE    | "5"    | pr_notice()           
 44 +----------------+--------+-------------------    
 45 | KERN_INFO      | "6"    | pr_info()             
 46 +----------------+--------+-------------------    
 47 | KERN_DEBUG     | "7"    | pr_debug() and pr_    
 48 +----------------+--------+-------------------    
 49 | KERN_DEFAULT   | ""     |                       
 50 +----------------+--------+-------------------    
 51 | KERN_CONT      | "c"    | pr_cont()             
 52 +----------------+--------+-------------------    
 53                                                   
 54                                                   
 55 The log level specifies the importance of a me    
 56 to show the message immediately (printing it t    
 57 on its log level and the current *console_logl    
 58 message priority is higher (lower log level va    
 59 the message will be printed to the console.       
 60                                                   
 61 If the log level is omitted, the message is pr    
 62 level.                                            
 63                                                   
 64 You can check the current *console_loglevel* w    
 65                                                   
 66   $ cat /proc/sys/kernel/printk                   
 67   4        4        1        7                    
 68                                                   
 69 The result shows the *current*, *default*, *mi    
 70 levels.                                           
 71                                                   
 72 To change the current console_loglevel simply     
 73 ``/proc/sys/kernel/printk``. For example, to p    
 74                                                   
 75   # echo 8 > /proc/sys/kernel/printk              
 76                                                   
 77 Another way, using ``dmesg``::                    
 78                                                   
 79   # dmesg -n 5                                    
 80                                                   
 81 sets the console_loglevel to print KERN_WARNIN    
 82 console. See ``dmesg(1)`` for more information    
 83                                                   
 84 As an alternative to printk() you can use the     
 85 logging. This family of macros embed the log l    
 86 example::                                         
 87                                                   
 88   pr_info("Info message no. %d\n", msg_num);      
 89                                                   
 90 prints a ``KERN_INFO`` message.                   
 91                                                   
 92 Besides being more concise than the equivalent    
 93 common definition for the format string throug    
 94 instance, defining this at the top of a source    
 95 directive)::                                      
 96                                                   
 97   #define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MO    
 98                                                   
 99 would prefix every pr_*() message in that file    
100 that originated the message.                      
101                                                   
102 For debugging purposes there are also two cond    
103 pr_debug() and pr_devel(), which are compiled-    
104 also ``CONFIG_DYNAMIC_DEBUG`` in the case of p    
105                                                   
106                                                   
107 Function reference                                
108 ==================                                
109                                                   
110 .. kernel-doc:: include/linux/printk.h            
111    :functions: printk pr_emerg pr_alert pr_cri    
112       pr_fmt pr_debug pr_devel pr_cont            
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php