LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

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

Rep: Reputation: 15
Using printk


Hi,

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

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

Rep: Reputation: 67
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.

Code:
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).
 
  


Reply


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 02:16 PM.

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