Skip to contentSkip to conversation

reduce syslog clutter

PATCH In review Tilman Schmidt 2 participants 3 messages Feb 23, 2006 – Feb 24, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reduce syslog clutter

The current versions of the err() / info() / warn() syslog macros insert __FILE__ at the beginning of the message, which expands to the complete path name of the source file within the kernel tree.

With the following patch, when used in a module, they'll insert the module name instead, which is significantly shorter and also tends to be more useful to users trying to make sense of a particular message.

The patch also adds macros for the KERN_NOTICE severity level which was so far uncatered for.

---

 include/linux/device.h |    2 ++
 include/linux/usb.h    |    8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
include/linux/device.h +2 -0
diff -ru linux-2.6.16-rc4/include/linux/device.h linux-2.6.16-rc4-new/include/linux/device.h
@@ -424,6 +424,8 @@
 	dev_printk(KERN_INFO , dev , format , ## arg)
 #define dev_warn(dev, format, arg...)		\
 	dev_printk(KERN_WARNING , dev , format , ## arg)
+#define dev_notice(dev, format, arg...)		\
+	dev_printk(KERN_NOTICE , dev , format , ## arg)
 
 /* Create alias, so I can be autoloaded. */
 #define MODULE_ALIAS_CHARDEV(major,minor) \
include/linux/usb.h +5 -3
diff -ru linux-2.6.16-rc4/include/linux/usb.h linux-2.6.16-rc4-new/include/linux/usb.h
@@ -1211,11 +1211,13 @@
 #endif
 
 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
-	__FILE__ , ## arg)
+	THIS_MODULE ? THIS_MODULE->name : __FILE__ , ## arg)
 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \
-	__FILE__ , ## arg)
+	THIS_MODULE ? THIS_MODULE->name : __FILE__ , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \
-	__FILE__ , ## arg)
+	THIS_MODULE ? THIS_MODULE->name : __FILE__ , ## arg)
+#define notice(format, arg...) printk(KERN_NOTICE "%s: " format "\n", \
+	THIS_MODULE ? THIS_MODULE->name : __FILE__ , ## arg)
 
 
 #endif  /* __KERNEL__ */
Signature · 4 lines
Tilman Schmidt                          E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
#1 lore raw
Quoted 3 lines · Tilman Schmidt

The current versions of the err() / info() / warn() syslog macros insert __FILE__ at the beginning of the message, which expands to the complete path name of the source file within the kernel tree.

Note, this is the usb usage, you might want to post this on the linux-usb-devel mailing list :)

Quoted 6 lines

With the following patch, when used in a module, they'll insert the module name instead, which is significantly shorter and also tends to be more useful to users trying to make sense of a particular message.

The patch also adds macros for the KERN_NOTICE severity level which was so far uncatered for.

Does anyone want to use it?

I suggest splitting this up into two different patches.

thanks,

greg k-h

#2 lore raw

Hello Greg,

thanks for your comments.

Quoted 7 lines · Greg KH
Quoted 3 lines · Tilman Schmidt

The current versions of the err() / info() / warn() syslog macros insert __FILE__ at the beginning of the message, which expands to the complete path name of the source file within the kernel tree.

Note, this is the usb usage, you might want to post this on the linux-usb-devel mailing list :)

Ok.

Quoted 8 lines
Quoted 6 lines

With the following patch, when used in a module, they'll insert the module name instead, which is significantly shorter and also tends to be more useful to users trying to make sense of a particular message.

The patch also adds macros for the KERN_NOTICE severity level which was so far uncatered for.

Does anyone want to use it?

Yes, me. :-)

In fact, they are being used in the Gigaset drivers which are currently in the process of being submitted for inclusion in the kernel tree, but their definitions are in the driver specific header file drivers/isdn/gigaset/gigaset.h, although they really belong with their brothers and sisters in usb.h / device.h.

Quoted 1 line

I suggest splitting this up into two different patches.

Ok.

Regards
Tilman

--
Tilman Schmidt E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)