ecore_drm: Set a libinput's log handler 42/89942/3
authorJengHyun Kang <jhyuni.kang@samsung.com>
Tue, 27 Sep 2016 14:19:50 +0000 (23:19 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Fri, 30 Sep 2016 06:12:08 +0000 (23:12 -0700)
Change-Id: Ic53c7afbf579f0b38fa17cd971f218ed451a1e2b

src/lib/ecore_drm/ecore_drm_inputs.c
src/lib/ecore_drm/ecore_drm_private.h [changed mode: 0755->0644]

index e42ac74..b9e7028 100644 (file)
@@ -446,11 +446,36 @@ const struct libinput_interface _input_interface =
    _cb_close_restricted,
 };
 
+static void
+ecore_drm_libinput_log_handler(struct libinput *libinput,
+                               enum libinput_log_priority priority,
+                               const char *format, va_list args)
+{
+   char buf[1024] = {0,};
+
+   vsprintf(buf, format, args);
+   switch (priority)
+     {
+        case LIBINPUT_LOG_PRIORITY_DEBUG:
+           DBG(buf);
+           break;
+        case LIBINPUT_LOG_PRIORITY_INFO:
+           INF(buf);
+           break;
+        case LIBINPUT_LOG_PRIORITY_ERROR:
+           ERR(buf);
+           break;
+        default:
+           break;
+     }
+}
+
 /* public functions */
 EAPI Eina_Bool 
 ecore_drm_inputs_create(Ecore_Drm_Device *dev)
 {
    Ecore_Drm_Input *input;
+   char *env;
 
    /* check for valid device */
    EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
@@ -479,6 +504,11 @@ ecore_drm_inputs_create(Ecore_Drm_Device *dev)
      }
 
    /* set libinput log priority */
+   if ((env = getenv(ECORE_DRM_ENV_LIBINPUT_LOG_DISABLE)) && (atoi(env) == 1))
+     libinput_log_set_handler(input->libinput, NULL);
+   else if ((env = getenv(ECORE_DRM_ENV_LIBINPUT_LOG_EINA_LOG)) && (atoi(env) == 1))
+     libinput_log_set_handler(input->libinput, ecore_drm_libinput_log_handler);
+
    libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
 
    /* assign udev seat */
@@ -560,6 +590,11 @@ ecore_drm_inputs_devices_create(Ecore_Drm_Device *dev)
      }
 
    /* set libinput log priority */
+   if ((env = getenv(ECORE_DRM_ENV_LIBINPUT_LOG_DISABLE)) && (atoi(env) == 1))
+     libinput_log_set_handler(input->libinput, NULL);
+   else if ((env = getenv(ECORE_DRM_ENV_LIBINPUT_LOG_EINA_LOG)) && (atoi(env) == 1))
+     libinput_log_set_handler(input->libinput, ecore_drm_libinput_log_handler);
+
    libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
 
    for (int i = 0; i < devices_num; i++)
old mode 100755 (executable)
new mode 100644 (file)
index bc5ffc3..c3ab37d
@@ -68,6 +68,9 @@
 # define EVDEV_SEAT_KEYBOARD (1 << 1)
 # define EVDEV_SEAT_TOUCH (1 << 2)
 
+# define ECORE_DRM_ENV_LIBINPUT_LOG_DISABLE "ECORE_DRM_LIBINPUT_LOG_DISABLE"
+# define ECORE_DRM_ENV_LIBINPUT_LOG_EINA_LOG "ECORE_DRM_LIBINPUT_LOG_EINA_LOG"
+
 # ifdef ERR
 #  undef ERR
 # endif