Support dlog logging system 24/68824/2
authorMinJeong Kim <minjjj.kim@samsung.com>
Tue, 3 May 2016 13:40:50 +0000 (22:40 +0900)
committerMinJeong Kim <minjjj.kim@samsung.com>
Tue, 10 May 2016 04:46:15 +0000 (13:46 +0900)
Change-Id: I644818309e5e3f96b67ae2c8f16832607c9a8ccc

configure.ac
packaging/enlightenment.spec
src/bin/Makefile.mk
src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_log.c
src/bin/e_log.h

index 2da2d3d..d34d92e 100755 (executable)
@@ -409,6 +409,14 @@ if test "x$have_ttrace" = "xyes"; then
        AC_DEFINE(ENABLE_TTRACE, 1, [ttrace available])
 fi
 
+# dlog
+PKG_CHECK_EXISTS([dlog], [have_dlog="yes"], [have_dlog="no"])
+AC_MSG_CHECKING([Have dlog logger])
+AC_MSG_RESULT([${have_dlog}])
+if test "x${have_dlog}" = "xyes"; then
+    AC_DEFINE([HAVE_DLOG], [1], [Define to 1 if you have dlog])
+fi
+
 AM_CONDITIONAL([HAVE_WAYLAND], [test "x${have_wayland}" = "xyes"])
 AM_CONDITIONAL([HAVE_WAYLAND_TBM], [test "x${have_wayland_tbm}" = "xyes"])
 AM_CONDITIONAL([HAVE_HWC], [test "x${have_hwc}" = "xyes"])
index 1cbaf26..55ba37a 100644 (file)
@@ -10,6 +10,7 @@ Source1001:     enlightenment.manifest
 
 BuildRequires:  eet-tools
 BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(ecore)
 BuildRequires:  pkgconfig(ecore-evas)
 BuildRequires:  pkgconfig(ecore-file)
index f7c9737..9f8abdb 100644 (file)
@@ -171,7 +171,7 @@ endif
 
 endif
 
-src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=1 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS)
+src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=1 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS) $(DLOG_CFLAGS)
 if HAVE_WAYLAND_TBM
 src_bin_enlightenment_CPPFLAGS += @WAYLAND_TBM_CFLAGS@ @ECORE_DRM_CFLAGS@
 endif
@@ -184,7 +184,7 @@ src/bin/e_main.c \
 $(enlightenment_src)
 
 src_bin_enlightenment_LDFLAGS = -export-dynamic
-src_bin_enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ @WAYLAND_LIBS@ -lm @SHM_OPEN_LIBS@ $(TTRACE_LIBS)
+src_bin_enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ @WAYLAND_LIBS@ -lm @SHM_OPEN_LIBS@ $(TTRACE_LIBS) $(DLOG_LIBS)
 if HAVE_WAYLAND_TBM
 src_bin_enlightenment_LDADD += @WAYLAND_TBM_LIBS@ @ECORE_DRM_LIBS@
 endif
index 3ce466e..a84e7ea 100644 (file)
@@ -557,6 +557,33 @@ _e_info_client_proc_eina_log_path(int argc, char **argv)
      }
 }
 
+#ifdef HAVE_DLOG
+static void
+_e_info_client_proc_dlog_switch(int argc, char **argv)
+{
+   uint32_t onoff;
+
+   EINA_SAFETY_ON_FALSE_RETURN(argc == 3);
+   EINA_SAFETY_ON_NULL_RETURN(argv[2]);
+
+   onoff = atoi(argv[2]);
+   if ((onoff == 1) || (onoff == 0))
+     {
+
+        if (!_e_info_client_eldbus_message_with_args("dlog", NULL, "i", onoff))
+          {
+             printf("Error to switch %s logging system using dlog logging.", onoff?"on":"off");
+             return;
+          }
+        if (onoff)
+          printf("Now you can try to track enlightenment log with dlog logging system.\n"
+                 "Track dlog with LOGTAG \"E20\" ex) dlogutil E20\n");
+        else
+          printf("Logging of enlightenment with dlog is disabled.\n");
+     }
+}
+#endif
+
 static void
 _cb_window_prop_get(const Eldbus_Message *msg)
 {
@@ -1132,6 +1159,14 @@ static struct
       "Set eina-log path in runtime",
       _e_info_client_proc_eina_log_path
    },
+#ifdef HAVE_DLOG
+   {
+      "dlog",
+      "[on:1,off:0]",
+      "Logging using dlog system (on:1, off:0)",
+      _e_info_client_proc_dlog_switch
+   },
+#endif
    {
       "prop", "[id]",
       "Print window infomation",
index 3286db6..f1fcaf9 100644 (file)
@@ -685,6 +685,26 @@ _e_info_server_cb_eina_log_path(const Eldbus_Service_Interface *iface EINA_UNUSE
    return reply;
 }
 
+#ifdef HAVE_DLOG
+static Eldbus_Message *
+_e_info_server_cb_dlog_switch(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   uint32_t onoff;
+
+   if (!eldbus_message_arguments_get(msg, "i", &onoff))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   if ((onoff == 1) || (onoff == 0))
+     e_log_dlog_enable(onoff);
+
+   return reply;
+}
+#endif
+
 static Eldbus_Message *
 _e_info_server_cb_rotation_query(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
 {
@@ -1187,6 +1207,9 @@ static const Eldbus_Method methods[] = {
    { "dump_topvwins", ELDBUS_ARGS({"s", "directory"}), NULL, _e_info_server_cb_topvwins_dump, 0 },
    { "eina_log_levels", ELDBUS_ARGS({"s", "eina log levels"}), NULL, _e_info_server_cb_eina_log_levels, 0 },
    { "eina_log_path", ELDBUS_ARGS({"s", "eina log path"}), NULL, _e_info_server_cb_eina_log_path, 0 },
+#ifdef HAVE_DLOG
+   { "dlog", ELDBUS_ARGS({"i", "using dlog"}), NULL, _e_info_server_cb_dlog_switch, 0},
+#endif
    { "get_window_prop", ELDBUS_ARGS({"us", "query_mode_value"}), ELDBUS_ARGS({"a(ss)", "array_of_ec"}), _e_info_server_cb_window_prop_get, 0},
    { "get_connected_clients", NULL, ELDBUS_ARGS({"a(ss)", "array of ec"}), _e_info_server_cb_connected_clients_get, 0 },
    { "rotation_query", ELDBUS_ARGS({"i", "query_rotation"}), NULL, _e_info_server_cb_rotation_query, 0},
index 5502c2e..326d98e 100644 (file)
@@ -10,12 +10,60 @@ static const char *_names[] = {
    "DBG",
 };
 
+#ifdef HAVE_DLOG
+static Eina_Bool _dlog_enabled = EINA_FALSE;
+#endif
+
 static void
 _e_log_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc EINA_UNUSED, int line, const char *fmt, void *data EINA_UNUSED, va_list args)
 {
    const char *color;
+#ifdef HAVE_DLOG
+   if (_dlog_enabled)
+     {
+        int log_level;
+        const char buf[512];
+        char tmp_log_level[512];
+
+        switch (level)
+          {
+           case EINA_LOG_LEVEL_CRITICAL:
+              log_level = DLOG_FATAL;
+              strcpy(tmp_log_level, "FATAL");
+              break;
+           case EINA_LOG_LEVEL_ERR:
+              log_level = DLOG_ERROR;
+              strcpy(tmp_log_level, "ERROR");
+              break;
+           case EINA_LOG_LEVEL_WARN:
+              log_level = DLOG_WARN;
+              strcpy(tmp_log_level, "WARNING");
+              break;
+           case EINA_LOG_LEVEL_INFO:
+              log_level = DLOG_INFO;
+              strcpy(tmp_log_level, "INFO");
+              break;
+           case EINA_LOG_LEVEL_DBG:
+              log_level = DLOG_DEBUG;
+              strcpy(tmp_log_level, "DEBUG");
+              break;
+           default:
+              log_level = DLOG_VERBOSE;
+              strcpy(tmp_log_level, "VERBOSE");
+              break;
+          }
+
+        vsnprintf((char *)buf, sizeof(buf), fmt, args);
 
+        dlog_print(log_level, LOG_TAG,
+                  "%s<%s> %30.30s:%04d %s",
+                  _names[level > EINA_LOG_LEVEL_DBG ? EINA_LOG_LEVEL_DBG : level],
+                  d->domain_str,file, line, buf);
+        return;
+     }
+#endif
    color = eina_log_level_color_get(level);
+
    fprintf(stdout,
            "%s%s<" EINA_COLOR_RESET "%s%s>" EINA_COLOR_RESET "%30.30s:%04d" EINA_COLOR_RESET " ",
            color, _names[level > EINA_LOG_LEVEL_DBG ? EINA_LOG_LEVEL_DBG : level],
@@ -24,12 +72,27 @@ _e_log_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, cons
    putc('\n', stdout);
 }
 
+#ifdef HAVE_DLOG
+EINTERN void
+e_log_dlog_enable(Eina_Bool enable)
+{
+   if (_dlog_enabled != enable)
+     _dlog_enabled = enable;
+}
+#endif
+
 EINTERN int
 e_log_init(void)
 {
    e_log_dom = eina_log_domain_register("e", EINA_COLOR_WHITE);
    eina_log_print_cb_set(_e_log_cb, NULL);
    eina_log_domain_level_set("e", 3);
+
+#ifdef HAVE_DLOG
+   if (getenv("E_LOG_DLOG_ENABLE"))
+     _dlog_enabled = EINA_TRUE;
+#endif
+
    return 1;
 }
 
index 5d47348..1729c8c 100644 (file)
@@ -4,6 +4,13 @@
 #ifndef E_LOG_H
 #define E_LOG_H
 
+#ifdef HAVE_DLOG
+# include <dlog.h>
+#  ifdef LOG_TAG
+#   undef LOG_TAG
+#  endif
+# define LOG_TAG "E20"
+#endif
 
 #ifdef E_LOGGING
 #undef DBG
 
 extern E_API int e_log_dom;
 
+#ifdef HAVE_DLOG
+EINTERN void e_log_dlog_enable(Eina_Bool enable);
+#endif
+
 EINTERN int e_log_init(void);
 EINTERN int e_log_shutdown(void);
 #else