Re: kernel support for non-English user messages

Daniel Stekloff (dsteklof@us.ibm.com)
Fri, 11 Apr 2003 14:31:14 -0700


On Friday 11 April 2003 02:04 pm, Ruth Ivimey-Cook wrote:
> At 10:21 11/04/2003, Riley Williams wrote:
> >It would also have to handle all the cases of...
> >
> > #define CMD_PRINT(x...) printk(KERN_INFO x)
> >
> >
> > CMD_PRINT("This is some useless information");
>
> Personally, I feel there ought to be a standard set of these macros that
> can be used. Everyone keeps reinventing the same wheel :-(

We are trying to add standard logging macros to the kernel. Our first goal is
to work with device driver writers to create useful macros that help prefix
important information to messages logged from device drivers. We feel it
would be useful for normal users, administrators, and service engineers to
link a specific message with a specific device: so you can identify which
device is erroring, for example.

A first set of these macros is already in the 2.5 kernel. At the bottom of
include/linux/device.h you'll find a set of dev_* macros:

/* debugging and troubleshooting/diagnostic helpers. */
#define dev_printk(level, dev, format, arg...) \
printk(level "%s %s: " format , (dev)->driver->name , (dev)->bus_id ,
## arg)

#ifdef DEBUG
#define dev_dbg(dev, format, arg...) \
dev_printk(KERN_DEBUG , dev , format , ## arg)
#else
#define dev_dbg(dev, format, arg...) do {} while (0)
#endif

#define dev_err(dev, format, arg...) \
dev_printk(KERN_ERR , dev , format , ## arg)
#define dev_info(dev, format, arg...) \
dev_printk(KERN_INFO , dev , format , ## arg)
#define dev_warn(dev, format, arg...) \
dev_printk(KERN_WARNING , dev , format , ## arg)

The idea behind the dev_printk macros is to identify the message with a
specific device and the driver it manages. The dev_printk macro prints a
corresponding driver name and bus id to identify the device and the driver.
One can easily use that bus_id to search sysfs for the specific device the to
which the message refers.

The dev_printk is a start. We could see separate macros for specific
subsystems. Another example could be a netdev_printk macro that identifies
not only the physical device by bus_id but adds the device interface
information to the message as well. So, if you were working on a system with
4 network devices, you'd know in the error message the network interface -
eth3 - and which physical device - bus_id.

Comments and suggestions are welcome.

Thanks,

Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/