[RFC/PATCH] xfree86: add xf86IDrvMsg and friends for input driver logging.
Peter Hutterer
peter.hutterer at who-t.net
Tue Jun 15 17:12:51 PDT 2010
Input driver messages are only standardised by convention, with the drivers
prefixing the device name to most messages. This makes it rather hard to
grep on "evdev" for example when looking for the evdev ouput.
This patch adds three new logging functions, modeled after xf86DrvMsg(), the
logging function for output drivers. New functions are
xf86IDrvMsg() - input driver log message in default verbosity.
xf86IDrvMsgVerb() - input driver log message in specified verbosity.
xf86VIDrvMsgVerb() - same as xf86IDrvMsgVerb() but takes a varargs
argument.
Default log format is <driver name>: <device name>: <message>.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Not sure if I want this in 1.9, I think it'll be part of the larger
refacturing that the input driver API needs anyway.
hw/xfree86/common/xf86.h | 8 +++++++
hw/xfree86/common/xf86Helper.c | 42 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index d8629a8..b08f539 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -51,6 +51,8 @@
#include "propertyst.h"
+struct _LocalDeviceRec; /* for xf86IDrvMsg */
+
/* General parameters */
extern _X_EXPORT int xf86DoConfigure;
extern _X_EXPORT int xf86DoShowOptions;
@@ -225,6 +227,12 @@ extern _X_EXPORT void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
extern _X_EXPORT void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
_X_ATTRIBUTE_PRINTF(3,4);
+extern _X_EXPORT void xf86VIDrvMsgVerb(struct _LocalDeviceRec *dev, MessageType type, int verb,
+ const char *format, va_list args);
+extern _X_EXPORT void xf86IDrvMsgVerb(struct _LocalDeviceRec *dev, MessageType type, int verb,
+ const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
+extern _X_EXPORT void xf86IDrvMsg(struct _LocalDeviceRec *dev, MessageType type, const char *format, ...)
+ _X_ATTRIBUTE_PRINTF(3,4);
extern _X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
_X_ATTRIBUTE_PRINTF(3,4);
extern _X_EXPORT void xf86Msg(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 1aad2d1..69c031d 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1262,6 +1262,48 @@ xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
va_end(ap);
}
+/* Print input driver messages in the standard format of
+ <driver>: <device name>: <message> */
+void
+xf86VIDrvMsgVerb(LocalDevicePtr dev, MessageType type, int verb, const char *format,
+ va_list args)
+{
+ char *tmpFormat;
+
+ tmpFormat = malloc(strlen(format)+ strlen(dev->drv->driverName) + strlen(dev->name) + 5);
+ if (!tmpFormat)
+ return;
+
+ sprintf(tmpFormat, "%s: %s: %s", dev->drv->driverName, dev->name, format);
+
+ LogVMessageVerb(type, verb, tmpFormat, args);
+ free(tmpFormat);
+}
+
+/* Print input driver message, with verbose level specified directly */
+void
+xf86IDrvMsgVerb(LocalDevicePtr dev, MessageType type, int verb, const char *format,
+ ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VIDrvMsgVerb(dev, type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Print input driver messages, with verbose level of 1 (default) */
+void
+xf86IDrvMsg(LocalDevicePtr dev, MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VIDrvMsgVerb(dev, type, 1, format, ap);
+ va_end(ap);
+}
+
+
/* Print non-driver messages with verbose level specified directly */
void
xf86MsgVerb(MessageType type, int verb, const char *format, ...)
--
1.7.0.1
More information about the xorg-devel
mailing list