* about printk and console_loglevel
@ 2011-03-05 18:42 Siddu
2011-03-05 20:08 ` Михаил Кринкин
2011-03-05 22:22 ` Andrzej Kardas
0 siblings, 2 replies; 4+ messages in thread
From: Siddu @ 2011-03-05 18:42 UTC (permalink / raw)
To: kernelnewbies
Hi all,
Hi all,
I am little stuck understanding this piece of code below and the way its
been working
Question: since KERN_INFO = 6 # which is msg_log_level
and as per code
*msg_log_level < console_loglevel*
this line of printk is not supposed to show up in the dmesg log ? but it is
showing up . Why
cat /proc/sys/kernel/printk
4 4 1 7
console_loglevel = 4
printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
static void _call_console_drivers(unsigned start,
unsigned end, int msg_log_level)
{
if ((*msg_log_level < console_loglevel* || ignore_loglevel) &&
console_drivers && start != end) {
if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
/* wrapped write */
__call_console_drivers(start & LOG_BUF_MASK,
log_buf_len);
__call_console_drivers(0, end & LOG_BUF_MASK);
} else {
__call_console_drivers(start, end);
}
}
}
Thanks for any inputs !
--
Regards,
~Sid~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110306/85e2e076/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread* about printk and console_loglevel
2011-03-05 18:42 about printk and console_loglevel Siddu
@ 2011-03-05 20:08 ` Михаил Кринкин
2011-03-05 22:22 ` Andrzej Kardas
1 sibling, 0 replies; 4+ messages in thread
From: Михаил Кринкин @ 2011-03-05 20:08 UTC (permalink / raw)
To: kernelnewbies
I think, that console and dmesg are not the same. console_loglevel mean
sumething like text terminal. parport and so on, but dmesg is independent
from this log level. You can write simple module like this:
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void) {
printk(KERN_EMERG "EMERG: Hello World.\n"); printk(KERN_ALERT
"ALERT: Hello World.\n"); printk(KERN_CRIT "CRIT: Hello World.\n");
printk(KERN_WARNING "WARNING: Hello World.\n"); printk(KERN_NOTICE "NOTICE:
Hello World.\n"); printk(KERN_INFO "INFO: Hello World.\n");
printk(KERN_DEBUG "DEBUG: Hello World.\n"); return 0;
}
void cleanup_module(void) {
printk("Bye :)");
}
and you see, that dmesg print everything (but /var/log/messages contained
only WARNING, NOTICE and INFO levels messages, for console_loglevel = 3)
2011/3/5 Siddu <siddu.sjce@gmail.com>
> Hi all,
> Hi all,
>
> I am little stuck understanding this piece of code below and the way its
> been working
>
> Question: since KERN_INFO = 6 # which is msg_log_level
> and as per code
> *msg_log_level < console_loglevel*
>
> this line of printk is not supposed to show up in the dmesg log ? but it
> is showing up . Why
>
> cat /proc/sys/kernel/printk
> 4 4 1 7
>
> console_loglevel = 4
>
> printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
>
>
> static void _call_console_drivers(unsigned start,
> unsigned end, int msg_log_level)
> {
> if ((*msg_log_level < console_loglevel* || ignore_loglevel) &&
> console_drivers && start != end) {
> if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
> /* wrapped write */
> __call_console_drivers(start & LOG_BUF_MASK,
> log_buf_len);
> __call_console_drivers(0, end & LOG_BUF_MASK);
> } else {
> __call_console_drivers(start, end);
> }
> }
> }
>
> Thanks for any inputs !
> --
> Regards,
> ~Sid~
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110305/0bd286a8/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread* about printk and console_loglevel
2011-03-05 18:42 about printk and console_loglevel Siddu
2011-03-05 20:08 ` Михаил Кринкин
@ 2011-03-05 22:22 ` Andrzej Kardas
2011-03-06 8:25 ` Siddu
1 sibling, 1 reply; 4+ messages in thread
From: Andrzej Kardas @ 2011-03-05 22:22 UTC (permalink / raw)
To: kernelnewbies
On 05.03.2011 19:42, Siddu wrote:
> Hi all,
> Hi all,
>
> I am little stuck understanding this piece of code below and the way
> its been working
>
> Question: since KERN_INFO = 6 # which is msg_log_level
> and as per code
> *msg_log_level < console_loglevel*
>
> this line of printk is not supposed to show up in the dmesg log ? but
> it is showing up . Why
console_loglevel concern messages that should display on the CONSOLE not
"dmesg" and controls if message is enough important (read: have prioryty
below *console_loglevel) *to display it on the console. You must know
that, kernel logs its messages into buffer (into the RAM) which have
constant size, when you type dmesg, you simply read messages from that
buffer (ring-buffer), so that why you see your line in dmesg.
What is more, there is deamon called syslog (rsyslog) which reads this
buffer periodically and saves messages in appropriate log file on the
hard drive e.g. /var/log/kern.log or /var/log/messages etc. You can
configure rsyslog as you wish, to log certain types messages into logfiles.
--
regards
Andrzej Kardas
http://www.linux.mynotes.pl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110305/0eb6069f/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* about printk and console_loglevel
2011-03-05 22:22 ` Andrzej Kardas
@ 2011-03-06 8:25 ` Siddu
0 siblings, 0 replies; 4+ messages in thread
From: Siddu @ 2011-03-06 8:25 UTC (permalink / raw)
To: kernelnewbies
Thank you ... I guess that answers :)
On Sun, Mar 6, 2011 at 3:52 AM, Andrzej Kardas <andrzej-kardas@o2.pl> wrote:
>
>
> On 05.03.2011 19:42, Siddu wrote:
>
> Hi all,
> Hi all,
>
> I am little stuck understanding this piece of code below and the way its
> been working
>
> Question: since KERN_INFO = 6 # which is msg_log_level
> and as per code
> *msg_log_level < console_loglevel*
>
> this line of printk is not supposed to show up in the dmesg log ? but it
> is showing up . Why
>
>
> console_loglevel concern messages that should display on the CONSOLE not
> "dmesg" and controls if message is enough important (read: have prioryty
> below *console_loglevel) *to display it on the console. You must know
> that, kernel logs its messages into buffer (into the RAM) which have
> constant size, when you type dmesg, you simply read messages from that
> buffer (ring-buffer), so that why you see your line in dmesg.
>
> What is more, there is deamon called syslog (rsyslog) which reads this
> buffer periodically and saves messages in appropriate log file on the hard
> drive e.g. /var/log/kern.log or /var/log/messages etc. You can configure
> rsyslog as you wish, to log certain types messages into logfiles.
>
>
> --
> regards
> Andrzej Kardas
> http://www.linux.mynotes.pl
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
--
Regards,
~Sid~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110306/d1102cb3/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-06 8:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-05 18:42 about printk and console_loglevel Siddu
2011-03-05 20:08 ` Михаил Кринкин
2011-03-05 22:22 ` Andrzej Kardas
2011-03-06 8:25 ` Siddu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.