--- /dev/null
+/*
+ * 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__ */
#include <amd.h>
#include "amd_watch.h"
+#include "amd_watch_logger.h"
struct watch_info {
char *appid;
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,
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)
EXPORT int AMD_MOD_INIT(void)
{
_D("watch init");
+ _watch_logger_init();
amd_noti_listen(AMD_NOTI_MSG_MAIN_APP_DEAD,
__on_app_dead);
g_list_free_full(__restart_list, __destroy_watch_info);
if (__update_list)
g_list_free_full(__update_list, __destroy_watch_info);
+ _watch_logger_fini();
}
--- /dev/null
+/*
+ * 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);
+}