2005-02-26 18:05:48

by Matthias Kunze

[permalink] [raw]
Subject: [PATCH] config option for default loglevel

Hi,

I've created a little patch to make the default loglevel a configurable
option. Is there a chance that this patch will be included in a future
release?

diff -Naur linux-2.6.10/drivers/video/console/Kconfig linux-2.6.10-new/drivers/video/console/Kconfig
--- linux-2.6.10/drivers/video/console/Kconfig 2004-12-24 22:34:26.000000000 +0100
+++ linux-2.6.10-new/drivers/video/console/Kconfig 2005-02-26 17:11:03.000000000 +0100
@@ -186,5 +186,25 @@
big letters (like the letters used in the SPARC PROM). If the
standard font is unreadable for you, say Y, otherwise say N.

+config DEFAULT_CONSOLE_LOGLEVEL
+ int "Default Console Loglevel"
+ range 1 8
+ default 7
+ help
+ All Kernel Messages with a loglevel smaller than the console loglevel
+ will be printed to the console. This value can later 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
+
+ The console loglevel can be set to a value in the range from 1 to 8.
+
endmenu

diff -Naur linux-2.6.10/kernel/printk.c linux-2.6.10-new/kernel/printk.c
--- linux-2.6.10/kernel/printk.c 2005-02-26 16:49:03.000000000 +0100
+++ linux-2.6.10-new/kernel/printk.c 2005-02-26 17:32:09.000000000 +0100
@@ -41,7 +41,7 @@

/* We show everything that is MORE important than this.. */
#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
-#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
+#define DEFAULT_CONSOLE_LOGLEVEL CONFIG_DEFAULT_CONSOLE_LOGLEVEL

DECLARE_WAIT_QUEUE_HEAD(log_wait);


---
Matthias Kunze
http://elpp.foofighter.de


2005-02-26 18:18:10

by Matthias-Christian Ott

[permalink] [raw]
Subject: Re: [PATCH] config option for default loglevel

Matthias Kunze wrote:

>Hi,
>
>I've created a little patch to make the default loglevel a configurable
>option. Is there a chance that this patch will be included in a future
>release?
>
>diff -Naur linux-2.6.10/drivers/video/console/Kconfig linux-2.6.10-new/drivers/video/console/Kconfig
>--- linux-2.6.10/drivers/video/console/Kconfig 2004-12-24 22:34:26.000000000 +0100
>+++ linux-2.6.10-new/drivers/video/console/Kconfig 2005-02-26 17:11:03.000000000 +0100
>@@ -186,5 +186,25 @@
> big letters (like the letters used in the SPARC PROM). If the
> standard font is unreadable for you, say Y, otherwise say N.
>
>+config DEFAULT_CONSOLE_LOGLEVEL
>+ int "Default Console Loglevel"
>+ range 1 8
>+ default 7
>+ help
>+ All Kernel Messages with a loglevel smaller than the console loglevel
>+ will be printed to the console. This value can later 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
>+
>+ The console loglevel can be set to a value in the range from 1 to 8.
>+
> endmenu
>
>diff -Naur linux-2.6.10/kernel/printk.c linux-2.6.10-new/kernel/printk.c
>--- linux-2.6.10/kernel/printk.c 2005-02-26 16:49:03.000000000 +0100
>+++ linux-2.6.10-new/kernel/printk.c 2005-02-26 17:32:09.000000000 +0100
>@@ -41,7 +41,7 @@
>
> /* We show everything that is MORE important than this.. */
> #define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
>-#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
>+#define DEFAULT_CONSOLE_LOGLEVEL CONFIG_DEFAULT_CONSOLE_LOGLEVEL
>
> DECLARE_WAIT_QUEUE_HEAD(log_wait);
>
>
>---
>Matthias Kunze
>http://elpp.foofighter.de
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to [email protected]
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
>
>
>
Hi!
I think this patch is useful and should be included in further Kernel
releases.

Matthias-Christian Ott

2005-02-26 23:45:40

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] config option for default loglevel

Matthias Kunze <[email protected]> wrote:
>
> I've created a little patch to make the default loglevel a configurable
> option.

It'd be better to make it a kernel boot option, IMO. We already have
`debug' and `quiet' (init/main.c), which are rather silly things. An
option to set the initial loglevel would make sense.

2005-02-27 02:04:26

by Matthias Kunze

[permalink] [raw]
Subject: Re: [PATCH] config option for default loglevel

Am Sat, 26 Feb 2005 15:45:05 -0800 schrieb Andrew Morton <[email protected]>:

> Matthias Kunze <[email protected]> wrote:
> >
> > I've created a little patch to make the default loglevel a configurable
> > option.
>
> It'd be better to make it a kernel boot option, IMO. We already have
> `debug' and `quiet' (init/main.c), which are rather silly things. An
> option to set the initial loglevel would make sense.
>

I've added the boot option, it will override the compile-time option.

diff -Naur linux-2.6.10/Documentation/kernel-parameters.txt linux-2.6.10-new/Documentation/kernel-parameters.txt
--- linux-2.6.10/Documentation/kernel-parameters.txt 2005-02-27 02:47:09.000000000 +0100
+++ linux-2.6.10-new/Documentation/kernel-parameters.txt 2005-02-27 02:52:36.000000000 +0100
@@ -634,6 +634,20 @@
logibm.irq= [HW,MOUSE] Logitech Bus Mouse Driver
Format: <irq>

+ 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
+
log_buf_len=n Sets the size of the printk ring buffer, in bytes.
Format is n, nk, nM. n must be a power of two. The
default is set in kernel config.
diff -Naur linux-2.6.10/drivers/video/console/Kconfig linux-2.6.10-new/drivers/video/console/Kconfig
--- linux-2.6.10/drivers/video/console/Kconfig 2004-12-24 22:34:26.000000000 +0100
+++ linux-2.6.10-new/drivers/video/console/Kconfig 2005-02-27 02:44:58.000000000 +0100
@@ -186,5 +186,26 @@
big letters (like the letters used in the SPARC PROM). If the
standard font is unreadable for you, say Y, otherwise say N.

+config DEFAULT_CONSOLE_LOGLEVEL
+ int "Default Console Loglevel"
+ range 1 8
+ default 7
+ help
+ All Kernel Messages with a loglevel smaller than the console loglevel
+ will be printed to the console. This value can be overriden by the
+ boot parameter loglevel=NUM. 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
+
+ The console loglevel can be set to a value in the range from 1 to 8.
+
endmenu

diff -Naur linux-2.6.10/init/main.c linux-2.6.10-new/init/main.c
--- linux-2.6.10/init/main.c 2005-02-27 02:48:32.000000000 +0100
+++ linux-2.6.10-new/init/main.c 2005-02-27 02:39:08.000000000 +0100
@@ -209,6 +209,14 @@
__setup("debug", debug_kernel);
__setup("quiet", quiet_kernel);

+static int __init loglevel(char *str)
+{
+ get_option(&str, &console_loglevel);
+ return 1;
+}
+
+__setup("loglevel=", loglevel);
+
/*
* Unknown boot options get handed to init, unless they look like
* failed parameters
diff -Naur linux-2.6.10/kernel/printk.c linux-2.6.10-new/kernel/printk.c
--- linux-2.6.10/kernel/printk.c 2005-02-27 02:48:32.000000000 +0100
+++ linux-2.6.10-new/kernel/printk.c 2005-02-27 02:39:18.000000000 +0100
@@ -41,7 +41,7 @@

/* We show everything that is MORE important than this.. */
#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
-#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
+#define DEFAULT_CONSOLE_LOGLEVEL CONFIG_DEFAULT_CONSOLE_LOGLEVEL

DECLARE_WAIT_QUEUE_HEAD(log_wait);

2005-02-27 02:16:35

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] config option for default loglevel

Matthias Kunze <[email protected]> wrote:
>
> I've added the boot option, it will override the compile-time option.

I don't see a need for the compile-time option now..

2005-02-27 02:19:08

by Andries Brouwer

[permalink] [raw]
Subject: Re: [PATCH] config option for default loglevel

On Sun, Feb 27, 2005 at 03:04:31AM +0100, Matthias Kunze wrote:

+config DEFAULT_CONSOLE_LOGLEVEL

You do not want to add yet another config option.
Config options are used to select or deselect major subsystems,
or support for specific hardware.
Not to tweak variables.

Adding more config variables is not an improvement.

There are many ways to set the loglevel from user space.
You add one on the command line - maybe useful in case more
output is needed when the kernel crashes in early boot.
I see no justification for DEFAULT_CONSOLE_LOGLEVEL.

Andries

2005-02-27 02:36:20

by Matthias Kunze

[permalink] [raw]
Subject: Re: [PATCH] config option for default loglevel

Am Sat, 26 Feb 2005 18:15:52 -0800 schrieb Andrew Morton <[email protected]>:

> I don't see a need for the compile-time option now..
>

Well i would prefer to also have a compile-time option, but only a boot
paramter will also do the job.

diff -Naur linux-2.6.10/Documentation/kernel-parameters.txt linux-2.6.10-new/Documentation/kernel-parameters.txt
--- linux-2.6.10/Documentation/kernel-parameters.txt 2005-02-27 02:47:09.000000000 +0100
+++ linux-2.6.10-new/Documentation/kernel-parameters.txt 2005-02-27 02:52:36.000000000 +0100
@@ -634,6 +634,20 @@
logibm.irq= [HW,MOUSE] Logitech Bus Mouse Driver
Format: <irq>

+ 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
+
log_buf_len=n Sets the size of the printk ring buffer, in bytes.
Format is n, nk, nM. n must be a power of two. The
default is set in kernel config.
diff -Naur linux-2.6.10/init/main.c linux-2.6.10-new/init/main.c
--- linux-2.6.10/init/main.c 2005-02-27 02:48:32.000000000 +0100
+++ linux-2.6.10-new/init/main.c 2005-02-27 02:39:08.000000000 +0100
@@ -209,6 +209,14 @@
__setup("debug", debug_kernel);
__setup("quiet", quiet_kernel);

+static int __init loglevel(char *str)
+{
+ get_option(&str, &console_loglevel);
+ return 1;
+}
+
+__setup("loglevel=", loglevel);
+
/*
* Unknown boot options get handed to init, unless they look like
* failed parameters