9 #include <linux/limits.h>
11 #include <app_common.h>
17 void sticker_save_log(const char *fmt, ...)
20 char time_buf[96] = {0};
21 char full_buf[4096] = {0};
22 char log_path[PATH_MAX];
23 char strLogFile[PATH_MAX];
27 clock_gettime(CLOCK_REALTIME, &ts);
28 const time_t tt = ts.tv_sec;
29 const long int real_millisec = ts.tv_nsec / 1000000;
31 struct tm *const ptm = localtime(&tt);
32 strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", ptm);
35 vsnprintf(buf, sizeof (buf), fmt, ap);
38 snprintf(full_buf, sizeof(full_buf), "%s.%03ld %s", time_buf, real_millisec, buf);
40 char *data_path = NULL;
41 data_path = app_get_shared_data_path();
42 snprintf(log_path, sizeof(log_path), "%s/log", data_path);
47 snprintf(strLogFile, sizeof(strLogFile), "%s/sticker.log", log_path);
49 std::ofstream sticker_log_file (strLogFile, std::ios::app);
50 sticker_log_file << full_buf << std::endl;
51 sticker_log_file.flush ();