summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyunho <hhstark.kang@samsung.com>2020-07-09 09:48:44 +0900
committerhyunho <hhstark.kang@samsung.com>2020-08-05 15:51:23 +0900
commit44de89e73b9ed018a41c25cd7bd653f9dbcd3197 (patch)
treeffd0808849c2d7d08508d3f3bc48c88699164260
parentd47c0aae7fc2caf3725022c27213b9191bbd59ee (diff)
downloadamd-44de89e73b9ed018a41c25cd7bd653f9dbcd3197.tar.gz
amd-44de89e73b9ed018a41c25cd7bd653f9dbcd3197.tar.bz2
amd-44de89e73b9ed018a41c25cd7bd653f9dbcd3197.zip
Add logs for watch launch/dead events
Change-Id: Ie447a099f4829b8b70babe4fb10c84916a9c65b2 Signed-off-by: hyunho <hhstark.kang@samsung.com>
-rw-r--r--modules/watch/inc/amd_watch_logger.h26
-rw-r--r--modules/watch/src/amd_watch.c11
-rw-r--r--modules/watch/src/amd_watch_logger.c58
3 files changed, 93 insertions, 2 deletions
diff --git a/modules/watch/inc/amd_watch_logger.h b/modules/watch/inc/amd_watch_logger.h
new file mode 100644
index 00000000..6cc30d2e
--- /dev/null
+++ b/modules/watch/inc/amd_watch_logger.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMD_WATCH_LOGGER_H__
+#define __AMD_WATCH_LOGGER_H__
+
+int _watch_logger_init(void);
+
+void _watch_logger_fini(void);
+
+int _watch_logger_print(const char *tag, const char *format, ...);
+
+#endif /* __AMD_WATCH_LOGGER_H__ */
diff --git a/modules/watch/src/amd_watch.c b/modules/watch/src/amd_watch.c
index 77daaa18..8d7c85c8 100644
--- a/modules/watch/src/amd_watch.c
+++ b/modules/watch/src/amd_watch.c
@@ -28,6 +28,7 @@
#include <amd.h>
#include "amd_watch.h"
+#include "amd_watch_logger.h"
struct watch_info {
char *appid;
@@ -59,7 +60,9 @@ static void __send_dead_signal(const char *appid, pid_t pid, uid_t uid,
amd_app_com_send("watch.dead", pid, envelope, uid);
bundle_free(envelope);
- _D("Send dead signal %s:%d:%u:%d", appid, pid, uid, is_faulted);
+ _I("Send dead signal %s:%d:%u:%d", appid, pid, uid, is_faulted);
+ _watch_logger_print("Send Dead", "appid(%s), pid(%d) "
+ "uid(%d), is_faulted(%d)", appid, pid, uid, is_faulted);
}
static void __send_launch_signal(const char *appid, const char *viewer,
@@ -81,7 +84,9 @@ static void __send_launch_signal(const char *appid, const char *viewer,
amd_app_com_send("watch.launch", pid, envelope, uid);
bundle_free(envelope);
- _D("Send launch signal %s:%d:%u", appid, pid, uid);
+ _I("Send launch signal %s:%d:%u", appid, pid, uid);
+ _watch_logger_print("Send Launch", "appid(%s), pid(%d) "
+ "uid(%d)", appid, pid, uid);
}
static void __destroy_watch_info(gpointer data)
@@ -314,6 +319,7 @@ static int __on_package_update_error(const char *msg, int arg1, int arg2,
EXPORT int AMD_MOD_INIT(void)
{
_D("watch init");
+ _watch_logger_init();
amd_noti_listen(AMD_NOTI_MSG_MAIN_APP_DEAD,
__on_app_dead);
@@ -337,4 +343,5 @@ EXPORT void AMD_MOD_FINI(void)
g_list_free_full(__restart_list, __destroy_watch_info);
if (__update_list)
g_list_free_full(__update_list, __destroy_watch_info);
+ _watch_logger_fini();
}
diff --git a/modules/watch/src/amd_watch_logger.c b/modules/watch/src/amd_watch_logger.c
new file mode 100644
index 00000000..a65fbaa4
--- /dev/null
+++ b/modules/watch/src/amd_watch_logger.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdarg.h>
+#include <amd.h>
+
+#include "amd_watch.h"
+#include "amd_logger.h"
+
+#define LOG_FILE "amd_watch.log"
+#define LOG_PATH LOGGER_PATH "/" LOG_FILE
+
+static amd_logger_h __logger;
+
+int _watch_logger_print(const char *tag, const char *format, ...)
+{
+ char format_buf[LOG_MAX_STRING_SIZE];
+ va_list ap;
+
+ va_start(ap, format);
+ vsnprintf(format_buf, sizeof(format_buf), format, ap);
+ va_end(ap);
+
+ return amd_logger_print(__logger, tag, format_buf);
+}
+
+int _watch_logger_init(void)
+{
+ int ret;
+
+ _D("watch logger init");
+ ret = amd_logger_create(LOG_PATH, &__logger);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+void _watch_logger_fini(void)
+{
+ _D("watch logger fini");
+ amd_logger_destroy(__logger);
+}