From: Jihoon Kim Date: Fri, 10 Apr 2020 04:32:03 +0000 (+0900) Subject: Add sticker-receiver log dump feature X-Git-Tag: accepted/tizen/5.5/unified/20200413.131115~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=76dbba6c38b81d1f9bda5c4e4a2f1ce444f6a83a;p=platform%2Fcore%2Fuifw%2Fcapi-ui-sticker.git Add sticker-receiver log dump feature Change-Id: Id37806ed564cc45f8b318dea4b26768d73a1017b Signed-off-by: Jihoon Kim --- diff --git a/dump/sticker_log_dump.sh b/dump/sticker_log_dump.sh new file mode 100755 index 0000000..2d0f875 --- /dev/null +++ b/dump/sticker_log_dump.sh @@ -0,0 +1,15 @@ +#!/bin/sh +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +#-------------------------------------- +# sticker +#-------------------------------------- +STICKER_DEBUG=$1/sticker +STICKER_HOME=/opt/usr/home/owner/apps_rw/.shared/org.tizen.sticker-receiver/data/log +STICKER_DB=/opt/dbspace/.sticker_info.db +/bin/mkdir -p ${STICKER_DEBUG} +/bin/cat ${STICKER_HOME}/sticker.log > ${STICKER_DEBUG}/sticker.log +/bin/cp ${STICKER_DB}/.sticker_info.db* ${STICKER_DEBUG}/ +/bin/sync + +##UEP330x4988b0767795e32b117da2c8c810260b9f03a2808cd45af44f4584cde4d17be8149fd2921bdbcf4b0d6c08ef97453b983cb72e238c6c64b33e8286148e7b377f906f66407eec37edd6fd431d93a217109003fa0ebc99560a67954fe2910fe35a02523c131fd0ab36de45f140db756fdda71f58e1d9d46575d0c2f5453575aaa08d47e6f13a657420020353981fb8e5998b29c9af70272613dffd33a97502e51ea926a258c6de56cc21d951d28b1e44f1e33ed5a530c5dfb9a72714a56d30894f02bf98fb9cfd1521102abbf46f50d38dc079321850685808ae0fd05a22822592bec5a1883d7937d990cbd59947829ea7c2c0d43333a2f0d72d53c6bcef426bb7AAACAg==:UEP diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index faae811..eb79cd5 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -114,6 +114,9 @@ find . -name '*.gcno' -exec cp '{}' gcov-obj ';' rm -rf %{buildroot} %make_install +mkdir -p %{buildroot}/%{TZ_SYS_ETC}/dump.d/module.d +cp -af dump/sticker_log_dump.sh %{buildroot}/%{TZ_SYS_ETC}/dump.d/module.d + mkdir -p %{buildroot}%{_prefix}/lib/systemd/system install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}/capi-ui-sticker.service @@ -157,6 +160,7 @@ chsmack -a "System::Shared" %{TZ_SYS_SHARE}/sticker-data %{TZ_SYS_RO_SHARE}/parser-plugins/capi-ui-sticker.info %{TZ_SYS_RO_ETC}/package-manager/parserlib/category/libcapi-ui-sticker-parser.so* %{TZ_SYS_RO_ETC}/package-manager/parserlib/metadata/libcapi-ui-sticker-parser.so* +%{TZ_SYS_ETC}/dump.d/module.d/* %files devel %manifest %{name}-devel.manifest diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index c9f9fc4..90c3837 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -7,6 +7,7 @@ SET(SRCS src/ft.cpp src/sticker_info.cpp src/message.cpp + src/sticker_log.cpp ) INCLUDE(FindPkgConfig) diff --git a/receiver/inc/log.h b/receiver/inc/log.h index 763f6cb..43a3aa6 100644 --- a/receiver/inc/log.h +++ b/receiver/inc/log.h @@ -18,34 +18,32 @@ #define __debug_H__ #include +#include +#include #undef LOG_TAG #define LOG_TAG "STICKER_RECEIVER" -#ifndef _LOG -#define _LOG(logLevel, fmt, ...) do { \ +void sticker_save_log (const char *fmt, ...); + +#define _STICKER_RECEIVER_LOG(logLevel, fmt, ...) do { \ dlog_print(logLevel, LOG_TAG, "%s : %s(%d) > " fmt, rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + sticker_save_log("pid(%d) %s : %s(%d) > " fmt, getpid(), rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ } while (0) -#endif -#ifndef LOGD -#define LOGD(format, arg...) _LOG(DLOG_DEBUG, format, ##arg) -#endif +#undef LOGD +#define LOGD(format, arg...) _STICKER_RECEIVER_LOG(DLOG_DEBUG, format, ##arg) -#ifndef LOGI -#define LOGI(format, arg...) _LOG(DLOG_INFO, format, ##arg) -#endif +#undef LOGI +#define LOGI(format, arg...) _STICKER_RECEIVER_LOG(DLOG_INFO, format, ##arg) -#ifndef LOGW -#define LOGW(format, arg...) _LOG(DLOG_WARN, format, ##arg) -#endif +#undef LOGW +#define LOGW(format, arg...) _STICKER_RECEIVER_LOG(DLOG_WARN, format, ##arg) -#ifndef LOGE -#define LOGE(format, arg...) _LOG(DLOG_ERROR, format, ##arg) -#endif +#undef LOGE +#define LOGE(format, arg...) _STICKER_RECEIVER_LOG(DLOG_ERROR, format, ##arg) -#ifndef LOGF -#define LOGF(format, arg...) _LOG(DLOG_FATAL, format, ##arg) -#endif +#undef LOGF +#define LOGF(format, arg...) _STICKER_RECEIVER_LOG(DLOG_FATAL, format, ##arg) #endif /* __debug_H__ */ \ No newline at end of file diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 2006985..0de1ef9 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -41,6 +41,20 @@ static bool app_create(void *data) LOGD(""); + char log_path[PATH_MAX]; + char *data_path = NULL; + data_path = app_get_shared_data_path(); + snprintf(log_path, sizeof(log_path), "%s/log", data_path); + + if (data_path) + free(data_path); + + if (access(log_path, F_OK) != 0) { + if (mkdir(log_path, 0755) == -1) { + LOGE("directory create error"); + } + } + return true; } diff --git a/receiver/src/sticker_log.cpp b/receiver/src/sticker_log.cpp new file mode 100644 index 0000000..8954a28 --- /dev/null +++ b/receiver/src/sticker_log.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "log.h" + +using namespace std; + +void sticker_save_log(const char *fmt, ...) +{ + char buf[4000] = {0}; + char time_buf[96] = {0}; + char full_buf[4096] = {0}; + char log_path[PATH_MAX]; + char strLogFile[PATH_MAX]; + va_list ap; + + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + const time_t tt = ts.tv_sec; + const long int real_millisec = ts.tv_nsec / 1000000; + + struct tm *const ptm = localtime(&tt); + strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", ptm); + + va_start(ap, fmt); + vsnprintf(buf, sizeof (buf), fmt, ap); + va_end(ap); + + snprintf(full_buf, sizeof(full_buf), "%s.%03ld %s", time_buf, real_millisec, buf); + + char *data_path = NULL; + data_path = app_get_shared_data_path(); + snprintf(log_path, sizeof(log_path), "%s/log", data_path); + + if (data_path) + free(data_path); + + snprintf(strLogFile, sizeof(strLogFile), "%s/sticker.log", log_path); + + std::ofstream sticker_log_file (strLogFile, std::ios::app); + sticker_log_file << full_buf << std::endl; + sticker_log_file.flush (); +}