e_info: support log feature to enable/disable specific log 20/310620/2
authorDoyoun Kang <doyoun.kang@samsung.com>
Thu, 2 May 2024 23:56:27 +0000 (08:56 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Fri, 3 May 2024 00:19:06 +0000 (00:19 +0000)
We add a -log command to enable/disable a specific log which is enabled/disabled by configuration.
Usage: winfo -log {log_type} (0 | 1)

Change-Id: Id8f1bf9b66c80c1e48f7c930c7e1702f5289c15b

src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_info_shared_types.h

index eec593b..6a9f7d1 100644 (file)
@@ -6775,6 +6775,58 @@ finish:
    return;
 }
 
+static void
+_e_info_client_log_control(int argc, char **argv)
+{
+   const char *type;
+   Eldbus_Message *msg;
+   Eldbus_Message_Iter *itr;
+   Eldbus_Pending *p;
+   uint32_t onoff;
+
+   if (argc < 4)
+     {
+        printf("Error Check Args (Need more arguments)\n");
+        printf(": enlightenment_info -log [type] [1:on, 0:off]\n");
+        return;
+     }
+
+   onoff = atoi(argv[3]);
+   if ((onoff != 0) && (onoff != 1))
+     {
+        printf("Error Check Args (Allowed 0 or 1)\n");
+        printf(": enlightenment_info -log [type] [1:on, 0:off]\n");
+        return;
+     }
+
+   type = argv[2];
+   if (eina_streq(type, "key_input_ttrace_enable") ||
+       eina_streq(type, "input_log_enable"))
+     {
+        msg = eldbus_proxy_method_call_new(e_info_client.proxy, "log_control");
+        itr = eldbus_message_iter_get(msg);
+        eldbus_message_iter_basic_append(itr, 's', type);
+        eldbus_message_iter_basic_append(itr, 'i', onoff);
+
+        p = eldbus_proxy_send(e_info_client.proxy, msg,
+                              _e_info_client_eldbus_message_cb,
+                              NULL, -1);
+        if (!p)
+          {
+             printf("Failed to call eldbus_proxy_send");
+             return;
+          }
+
+        ecore_main_loop_begin();
+     }
+   else
+     {
+        // not supported log
+        printf("Error Check Args (Not supported log type)\n");
+        printf(": enlightenment_info -log [type] [1:on, 0:off]\n");
+     }
+}
+
 typedef struct _ProcInfo
 {
    const char *option;
@@ -7191,6 +7243,12 @@ static ProcInfo procs_to_execute[] =
       "Set/Unset transparent of the kvm service window",
       _e_info_client_proc_kvm_transparent_set
    },
+   {
+      "log",
+      USAGE_LOG_CONTROL,
+      "Enable/Disable specific log",
+      _e_info_client_log_control
+   },
 };
 
 ProcInfo procs_to_input[] =
index d63a343..0bd549b 100644 (file)
@@ -7617,6 +7617,31 @@ _e_info_server_cb_kvm_transparent_set(const Eldbus_Service_Interface *iface EINA
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_log_control(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   const char *type;
+   uint32_t onoff;
+
+   if (!eldbus_message_arguments_get(msg, "si", &type, &onoff))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   if (!e_util_strcmp("key_input_ttrace_enable", type))
+     {
+        e_config->key_input_ttrace_enable = onoff;
+     }
+   else if (!e_util_strcmp("input_log_enable", type))
+     {
+        e_info_server_input_log_enable_set(onoff);
+     }
+
+   return reply;
+}
+
 //{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"iiiiisiiia("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
@@ -7724,6 +7749,7 @@ static const Eldbus_Method methods[] = {
    { "prop_set", ELDBUS_ARGS({"s","window id" }, {"s", "property"}, {"i", "set value"}), NULL, _e_info_server_cb_prop_set, 0},
    { "input_subtype_set", ELDBUS_ARGS({"ss", "set input device's subtype(subclas)"}), ELDBUS_ARGS({"s", "result message"}), _e_info_server_cb_input_subtype_set, 0 },
    { "kvm_transparent", ELDBUS_ARGS({"i", "set kvm service window to transparent"}), NULL, _e_info_server_cb_kvm_transparent_set, 0 },
+   { "log_control", ELDBUS_ARGS({"s","log type" }, {"i", "enable"}), NULL, _e_info_server_cb_log_control, 0},
    { NULL, NULL, NULL, NULL, 0 }
 };
 
index 488ffe0..6249fcc 100644 (file)
@@ -353,4 +353,13 @@ typedef enum
    "\twinfo -quickpanel 3 : unset scoll_lock for quickpanel service\n"          \
    "\twinfo -quickpanel 1 0x0a710a07 : show the specific quickpanel service\n"
 
+#define USAGE_LOG_CONTROL                        \
+   "{log type} (1 | 0) \n"                       \
+   "\tlog type : log type to enable/disable\n"   \
+   "\t           input_log_enable\n"             \
+   "\t           key_input_ttrace_enable\n"      \
+   "Example:\n"                                  \
+   "\twinfo -log input_log_enable 1\n"           \
+   "\twinfo -log key_input_ttrace_enable 1\n"
+
 #endif /* end of _E_INFO_SHARED_TYPES_ */