From d92580ba63ba1cf6dcf9b05e094559f584358ba9 Mon Sep 17 00:00:00 2001 From: MinJeong Kim Date: Tue, 3 May 2016 22:40:50 +0900 Subject: [PATCH] Support dlog logging system Change-Id: I644818309e5e3f96b67ae2c8f16832607c9a8ccc --- configure.ac | 8 ++++++ packaging/enlightenment.spec | 1 + src/bin/Makefile.mk | 4 +-- src/bin/e_info_client.c | 35 ++++++++++++++++++++++++ src/bin/e_info_server.c | 23 ++++++++++++++++ src/bin/e_log.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_log.h | 11 ++++++++ 7 files changed, 143 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2da2d3d..d34d92e 100755 --- a/configure.ac +++ b/configure.ac @@ -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"]) diff --git a/packaging/enlightenment.spec b/packaging/enlightenment.spec index 1cbaf26..55ba37a 100644 --- a/packaging/enlightenment.spec +++ b/packaging/enlightenment.spec @@ -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) diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk index f7c9737..9f8abdb 100644 --- a/src/bin/Makefile.mk +++ b/src/bin/Makefile.mk @@ -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 diff --git a/src/bin/e_info_client.c b/src/bin/e_info_client.c index 3ce466e..a84e7ea 100644 --- a/src/bin/e_info_client.c +++ b/src/bin/e_info_client.c @@ -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", diff --git a/src/bin/e_info_server.c b/src/bin/e_info_server.c index 3286db6..f1fcaf9 100644 --- a/src/bin/e_info_server.c +++ b/src/bin/e_info_server.c @@ -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}, diff --git a/src/bin/e_log.c b/src/bin/e_log.c index 5502c2e..326d98e 100644 --- a/src/bin/e_log.c +++ b/src/bin/e_log.c @@ -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; } diff --git a/src/bin/e_log.h b/src/bin/e_log.h index 5d47348..1729c8c 100644 --- a/src/bin/e_log.h +++ b/src/bin/e_log.h @@ -4,6 +4,13 @@ #ifndef E_LOG_H #define E_LOG_H +#ifdef HAVE_DLOG +# include +# ifdef LOG_TAG +# undef LOG_TAG +# endif +# define LOG_TAG "E20" +#endif #ifdef E_LOGGING #undef DBG @@ -49,6 +56,10 @@ 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 -- 2.7.4