Showing posts with label printk. Show all posts
Showing posts with label printk. Show all posts

Friday, March 7, 2008

Printk() problem solved !!!

Prink()'s on my systems seem to come as <4> = KERN_WARNING from all my dccp kernel codes.

In order to catch them (by neck :@), the trick was to kill "klogd" and restart it with the following options ::

klogd -x -f - -n -c 8

This will log everything conveniently on the console which can easily be redirected to any file if needed, finally leaving me in peace with exactly what I wanted ;) God bless "klogd" !!!

Thursday, March 6, 2008

Printk ()

Links::

Example::
printk( KERN_ERR "Failed to register device %s with major %d\n", MOD_NAME, MAJOR);

It is possible to read and modify the console loglevel using the text file
/proc/sys/kernel/printk.

The file hosts four integer values:
  • current loglevel,
  • default level for messages that lack an explicit loglevel,
  • minimum allowed loglevel
  • the boot-time default loglevel.
Writing a single value to this file changes the current loglevel to that value; thus, for example, you can cause all kernel messages to appear at the console by simply entering:



# echo 8 > /proc/sys/kernel/printk


KERN_* parameters are defined in

include/linux/kernel.h
as follows:



Macro NameNumeric Value
Description
KERN_EMERG0Used for emergency messages, usually those that precede a crash.

KERN_ALERT1A situation requiring immediate action.

KERN_CRIT2Critical conditions, often related to serious hardware or software failures.

KERN_ERR3Used to report error conditions; device drivers often use KERN_ERR to report hardware difficulties.

KERN_WARNING4Warnings about problematic situations that do not, in themselves, create serious problems with the system.

KERN_NOTICE5Situations that are normal, but still worthy of note. A number of security-related conditions are reported at this level.

KERN_INFO6Informational messages. Many drivers print information about the hardware they find at startup time at this level.

KERN_DEBUG7Used for debugging messages.