Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
console_loglevel [2018/11/23 13:34] – [lib/Kconfig.debug] rpjdayconsole_loglevel [2018/11/23 15:33] (current) – [Overview] rpjday
Line 1: Line 1:
 ===== Overview ===== ===== Overview =====
  
-How to mess with ''loglevel'' at boot time.+Properties of console loglevel, and how to use it.
  
 ===== Files ===== ===== Files =====
Line 15: Line 15:
     * [[https://github.com/torvalds/linux/blob/master/init/main.c|main.c]]     * [[https://github.com/torvalds/linux/blob/master/init/main.c|main.c]]
   * [[https://github.com/torvalds/linux/tree/master/kernel|kernel/]]   * [[https://github.com/torvalds/linux/tree/master/kernel|kernel/]]
 +    * [[https://github.com/torvalds/linux/blob/master/kernel/sysctl.c|sysctl.c]]
     * [[https://github.com/torvalds/linux/tree/master/kernel/printk|printk/]]     * [[https://github.com/torvalds/linux/tree/master/kernel/printk|printk/]]
       * [[https://github.com/torvalds/linux/blob/master/kernel/printk/printk.c|printk.c]]       * [[https://github.com/torvalds/linux/blob/master/kernel/printk/printk.c|printk.c]]
Line 26: Line 27:
   * /sys/module/printk/parameters   * /sys/module/printk/parameters
   * /proc/sys/kernel/printk/*   * /proc/sys/kernel/printk/*
 +
 +===== Kernel parameters =====
 +
 +<code>
 +loglevel=       All Kernel Messages with a loglevel smaller than the
 +                console loglevel will be printed to the console. It can
 +                also be changed with klogd or other programs. The
 +                loglevels are defined as follows:
 +
 +                0 (KERN_EMERG)          system is unusable
 +                1 (KERN_ALERT)          action must be taken immediately
 +                2 (KERN_CRIT)           critical conditions
 +                3 (KERN_ERR)            error conditions
 +                4 (KERN_WARNING)        warning conditions
 +                5 (KERN_NOTICE)         normal but significant condition
 +                6 (KERN_INFO)           informational
 +                7 (KERN_DEBUG)          debug-level messages
 +</code>
 +
 +<code>
 +ignore_loglevel [KNL]
 +                Ignore loglevel setting - this will print /all/
 +                kernel messages to the console. Useful for debugging.
 +                We also add it as printk module parameter, so users
 +                could change it dynamically, usually by
 +                /sys/module/printk/parameters/ignore_loglevel.
 +</code>
  
 ===== Kernel source files ===== ===== Kernel source files =====
  
 +==== kernel/printk/printk.c ====
 +
 +<code>
 +int console_printk[4] = {
 + CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
 + MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */
 + CONSOLE_LOGLEVEL_MIN, /* minimum_console_loglevel */
 + CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */
 +};
 +</code>
 +
 +==== include/linux/printk.h ====
 +
 +<code>
 +/* printk's without a loglevel use this.. */
 +#define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT
 +
 +/* We show everything that is MORE important than this.. */
 +#define CONSOLE_LOGLEVEL_SILENT  0 /* Mum's the word */
 +#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
 +#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
 +#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
 +
 +/*
 + * Default used to be hard-coded at 7, quiet used to be hardcoded at 4,
 + * we're now allowing both to be set from kernel config.
 + */
 +#define CONSOLE_LOGLEVEL_DEFAULT CONFIG_CONSOLE_LOGLEVEL_DEFAULT
 +#define CONSOLE_LOGLEVEL_QUIET CONFIG_CONSOLE_LOGLEVEL_QUIET
 +
 +extern int console_printk[];
 +
 +#define console_loglevel (console_printk[0])
 +#define default_message_loglevel (console_printk[1])
 +#define minimum_console_loglevel (console_printk[2])
 +#define default_console_loglevel (console_printk[3])
 +
 +static inline void console_silent(void)
 +{
 + console_loglevel = CONSOLE_LOGLEVEL_SILENT;
 +}
 +
 +static inline void console_verbose(void)
 +{
 + if (console_loglevel)
 + console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
 +}
 +</code>
 ==== lib/Kconfig.debug ==== ==== lib/Kconfig.debug ====
  
Line 72: Line 148:
    by default. To change that, use loglevel=<x> in the kernel bootargs,    by default. To change that, use loglevel=<x> in the kernel bootargs,
 or pick a different CONSOLE_LOGLEVEL_DEFAULT configuration value. or pick a different CONSOLE_LOGLEVEL_DEFAULT configuration value.
-</code> 
- 
-==== include/linux/printk.h ==== 
- 
-<code> 
-/* printk's without a loglevel use this.. */ 
-#define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT 
- 
-/* We show everything that is MORE important than this.. */ 
-#define CONSOLE_LOGLEVEL_SILENT  0 /* Mum's the word */ 
-#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */ 
-#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */ 
-#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */ 
-#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */ 
- 
-/* 
- * Default used to be hard-coded at 7, we're now allowing it to be set from 
- * kernel config. 
- */ 
-#define CONSOLE_LOGLEVEL_DEFAULT CONFIG_CONSOLE_LOGLEVEL_DEFAULT 
- 
-extern int console_printk[]; 
- 
-#define console_loglevel (console_printk[0]) 
-#define default_message_loglevel (console_printk[1]) 
-#define minimum_console_loglevel (console_printk[2]) 
-#define default_console_loglevel (console_printk[3]) 
- 
-static inline void console_silent(void) 
-{ 
- console_loglevel = CONSOLE_LOGLEVEL_SILENT; 
-} 
- 
-static inline void console_verbose(void) 
-{ 
- if (console_loglevel) 
- console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH; 
-} 
 </code> </code>
  
  • console_loglevel.1542980063.txt.gz
  • Last modified: 2018/11/23 13:34
  • by rpjday