Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-10-2005, 01:31 PM   #1
Registered: Sep 2005
Posts: 53

Rep: Reputation: 15
Using printk


Can any one say me how to use printk for printing from the kernel. Where did the printed messages will be? How to display that on the konsole

Old 10-10-2005, 04:07 PM   #2
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 68
int printk(const char *fmt, ) works very much like int printf(const char *fmt, ), with one notable exception.

The first parameter to printk can be replaced with an integer value, which is called the log level. This decides where the message goes, which can be to the kernel's log book (a 16kb memory block; see dmesg), or to the console.

The levels normally range from 0 (emergency; system unusable) to 7 (debugging), and are controlled by the constants KERN_EMERG, KERN_ALERT, KERN_CRIT, KERN_ERR, KERN_WARNING, KERN_NOTICE, KERN_INFO and KERN_DEBUG.

The compile-time flag CON_ENABLED is used when compiling the printk function to enable logging to the console. If set, and a console driver is loaded, then any message printed over the value of console_loglevel will be write()n to the console driver. The syslog() system call changes the console loglevel, which is normally done from user space when debugging a module; the default value is 7.

long sys_syslog(int type, char *buf, int len)
type can be 6 (sets the loglevel to 1), 7 (sets the loglevel to 7) or 8 (sets the loglevel to len, which must be between 0 and 9. Returns 0; I think buf is ignored (otherwise set it to log_start+log_size, which I think are globals).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
printk in the interrupt handler lordofring Programming 3 08-23-2005 09:00 PM
printk messages in Fedora 2 TracyHarmer Linux - Newbie 3 11-28-2004 05:42 PM
Regarding printk eshwar_ind Programming 0 11-23-2004 07:17 AM
printk: message ernobe Debian 4 11-20-2004 12:50 PM
printk or /proc unosoft Linux - Software 0 10-22-2003 05:05 PM

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration