linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* dumb question: How to create your own log files in a kernel module?
@ 2005-04-28 18:10 Xin Zhao
  2005-04-28 20:06 ` Richard B. Johnson
  2005-04-28 22:04 ` Chris Wedgwood
  0 siblings, 2 replies; 6+ messages in thread
From: Xin Zhao @ 2005-04-28 18:10 UTC (permalink / raw)
  To: linux-kernel

Can anyone give me a hand? or point me to somewhere I can find related
information?

Thanks in advance!

Xin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dumb question: How to create your own log files in a kernel module?
  2005-04-28 18:10 dumb question: How to create your own log files in a kernel module? Xin Zhao
@ 2005-04-28 20:06 ` Richard B. Johnson
  2005-04-28 20:59   ` Xin Zhao
  2005-04-28 22:04 ` Chris Wedgwood
  1 sibling, 1 reply; 6+ messages in thread
From: Richard B. Johnson @ 2005-04-28 20:06 UTC (permalink / raw)
  To: Xin Zhao; +Cc: linux-kernel

On Thu, 28 Apr 2005, Xin Zhao wrote:

> Can anyone give me a hand? or point me to somewhere I can find related
> information?
>
> Thanks in advance!
>
> Xin


printk(KERN_XXX"whatever") was designed for this.

#define	KERN_EMERG	"<0>"	/* system is unusable			*/
#define	KERN_ALERT	"<1>"	/* action must be taken immediately	*/
#define	KERN_CRIT	"<2>"	/* critical conditions			*/
#define	KERN_ERR	"<3>"	/* error conditions			*/
#define	KERN_WARNING	"<4>"	/* warning conditions			*/
#define	KERN_NOTICE	"<5>"	/* normal but significant condition	*/
#define	KERN_INFO	"<6>"	/* informational			*/
#define	KERN_DEBUG	"<7>"	/* debug-level messages			*/
 	printk(KERN_DEBUG fmt,##arg)
 	printk(KERN_INFO fmt,##arg)

You could define your own, KERN_PRIVATE "<8>" and have the syslog
facility filter on that.

Other ways are to write stuff to a buffer or linked-list and
read it out using an ioctl() or read() in your module. If you
do this, make sure that your module code doesn't wait forever
if the buffer gets full.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dumb question: How to create your own log files in a kernel module?
  2005-04-28 20:06 ` Richard B. Johnson
@ 2005-04-28 20:59   ` Xin Zhao
  2005-04-28 22:00     ` Michael Opdenacker
  0 siblings, 1 reply; 6+ messages in thread
From: Xin Zhao @ 2005-04-28 20:59 UTC (permalink / raw)
  To: linux-os; +Cc: linux-kernel

Thanks for kind help. 

I know printk can do this job. But what I really want is to print logs
to a file specified by me instead of /var/log/messages. And, the
messages irrelevant to my module should not be written into that file.
 Now my log mixed with other logs in /var/log/message, which bother me
much. :(

I guess the KERN_PRIVATE might work for this. Can you give me more details?

Thanks again!

Xin

On 4/28/05, Richard B. Johnson <linux-os@analogic.com> wrote:
> On Thu, 28 Apr 2005, Xin Zhao wrote:
> 
> > Can anyone give me a hand? or point me to somewhere I can find related
> > information?
> >
> > Thanks in advance!
> >
> > Xin
> 
> printk(KERN_XXX"whatever") was designed for this.
> 
> #define KERN_EMERG      "<0>"   /* system is unusable                   */
> #define KERN_ALERT      "<1>"   /* action must be taken immediately     */
> #define KERN_CRIT       "<2>"   /* critical conditions                  */
> #define KERN_ERR        "<3>"   /* error conditions                     */
> #define KERN_WARNING    "<4>"   /* warning conditions                   */
> #define KERN_NOTICE     "<5>"   /* normal but significant condition     */
> #define KERN_INFO       "<6>"   /* informational                        */
> #define KERN_DEBUG      "<7>"   /* debug-level messages                 */
>         printk(KERN_DEBUG fmt,##arg)
>         printk(KERN_INFO fmt,##arg)
> 
> You could define your own, KERN_PRIVATE "<8>" and have the syslog
> facility filter on that.
> 
> Other ways are to write stuff to a buffer or linked-list and
> read it out using an ioctl() or read() in your module. If you
> do this, make sure that your module code doesn't wait forever
> if the buffer gets full.
> 
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
>   Notice : All mail here is now cached for review by Dictator Bush.
>                   98.36% of all statistics are fiction.
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dumb question: How to create your own log files in a kernel module?
  2005-04-28 20:59   ` Xin Zhao
@ 2005-04-28 22:00     ` Michael Opdenacker
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Opdenacker @ 2005-04-28 22:00 UTC (permalink / raw)
  To: Xin Zhao; +Cc: linux-os, linux-kernel

Hi Xin,

>I know printk can do this job. But what I really want is to print logs
>to a file specified by me instead of /var/log/messages. And, the
>messages irrelevant to my module should not be written into that file.
> Now my log mixed with other logs in /var/log/message, which bother me
>much. :(
>
You seem to make a confusion here...

Don't forget that files are only an abstraction for userspace. They are 
only meant to be read and written from userspace. Kernel code can never 
read or write files. In the case of /var/log/messages, this file is 
created by the syslogd program from the kernel buffer, not by the kernel 
itself.

You could just echo something specific to your driver in your printk 
strings, and grep this specific thing in /var/log/messages. You have 
your file!

    Cheers,

    Michael.

-- 
Michael Opdenacker
http://free-electrons.com
+33 621 604 642


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dumb question: How to create your own log files in a kernel module?
  2005-04-28 18:10 dumb question: How to create your own log files in a kernel module? Xin Zhao
  2005-04-28 20:06 ` Richard B. Johnson
@ 2005-04-28 22:04 ` Chris Wedgwood
  1 sibling, 0 replies; 6+ messages in thread
From: Chris Wedgwood @ 2005-04-28 22:04 UTC (permalink / raw)
  To: Xin Zhao; +Cc: linux-kernel

On Thu, Apr 28, 2005 at 02:10:39PM -0400, Xin Zhao wrote:

> Can anyone give me a hand? or point me to somewhere I can find
> related information?

man syslogd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dumb question: How to create your own log files in a kernel module?
       [not found]   ` <3YoqV-2JA-31@gated-at.bofh.it>
@ 2005-04-28 23:28     ` Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org>
  0 siblings, 0 replies; 6+ messages in thread
From: Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org> @ 2005-04-28 23:28 UTC (permalink / raw)
  To: Xin Zhao, linux-kernel

Xin Zhao <uszhaoxin@gmail.com> wrote:

> Thanks for kind help.
> 
> I know printk can do this job. But what I really want is to print logs
> to a file specified by me instead of /var/log/messages.

RTFM.

man 5 syslogd.conf
-- 
Funny quotes:
39. Ever wonder about those people who spend $2.00 apiece on those little
    bottles of Evian water? Try spelling Evian backwards: NAIVE


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-04-28 23:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-28 18:10 dumb question: How to create your own log files in a kernel module? Xin Zhao
2005-04-28 20:06 ` Richard B. Johnson
2005-04-28 20:59   ` Xin Zhao
2005-04-28 22:00     ` Michael Opdenacker
2005-04-28 22:04 ` Chris Wedgwood
     [not found] <3YlMk-iH-9@gated-at.bofh.it>
     [not found] ` <3YnEA-1VB-27@gated-at.bofh.it>
     [not found]   ` <3YoqV-2JA-31@gated-at.bofh.it>
2005-04-28 23:28     ` Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org>

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).