[PATCH 13/19] xfree86: add xf86IDrvMsg and friends for input driver logging.

Peter Hutterer peter.hutterer at who-t.net
Thu Jul 29 23:21:29 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>
---
 hw/xfree86/common/xf86Helper.c |   37 +++++++++++++++++++++++++++++++++++++
 hw/xfree86/common/xf86Xinput.h |   11 +++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 8eccb22..8f5ca45 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1190,6 +1190,43 @@ 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 *msg;
+
+    msg = Xprintf("%s: %s: %s", dev->drv->driverName, dev->name, format);
+    LogVMessageVerb(type, verb, "%s", msg);
+    free(msg);
+}
+
+/* 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, ...)
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 4851f8b..943e181 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -192,6 +192,17 @@ extern _X_EXPORT InputDriverPtr xf86LookupInputDriver(const char *name);
 extern _X_EXPORT InputInfoPtr xf86LookupInput(const char *name);
 extern _X_EXPORT void xf86DeleteInput(InputInfoPtr pInp, int flags);
 extern _X_EXPORT void xf86MotionHistoryAllocate(LocalDevicePtr local);
+extern _X_EXPORT void xf86IDrvMsgVerb(LocalDevicePtr dev,
+				      MessageType type, int verb,
+				      const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
+extern _X_EXPORT void xf86IDrvMsg(LocalDevicePtr dev,
+				  MessageType type,
+				  const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
+extern _X_EXPORT void xf86VIDrvMsgVerb(LocalDevicePtr dev,
+				       MessageType type,
+				       int verb,
+				       const char *format,
+				       va_list args);
 
 /* xf86Option.c */
 extern _X_EXPORT void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
-- 
1.7.2



More information about the xorg-devel mailing list