Fix file logging format 80/238580/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 15 Jul 2020 08:22:28 +0000 (17:22 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 15 Jul 2020 08:22:28 +0000 (17:22 +0900)
Change-Id: I0d505736051b4ad43fedb06bf20790f9fe15e3fd
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/installer/app_installer.cc
src/common/utils/file_logbackend.cc

index e5636fb..a8d0b6b 100644 (file)
@@ -223,9 +223,8 @@ void AppInstaller::LogHistoryStart() {
   std::shared_ptr<utils::FileLogBackend> history_logger =
       std::shared_ptr<utils::FileLogBackend>(new utils::FileLogBackend(
           kHistoryFileName, kLogRotationSize, kLogMaximumRotation));
-  std::string history = "pkgid:" + context_->pkgid.get() + "|mode:" +
-      GetRequestTypeString(context_->request_type.get());
-  history += "|START";
+  std::string history = context_->pkgid.get() + "|" +
+      GetRequestTypeString(context_->request_type.get()) + "|START";
   history_logger->WriteLog(::utils::LogLevel::LOG_INFO, "", history);
   history_logger->WriteLogToFile();
 }
@@ -234,7 +233,7 @@ void AppInstaller::LogHistoryEnd(bool success) {
   std::shared_ptr<utils::FileLogBackend> history_logger =
       std::shared_ptr<utils::FileLogBackend>(new utils::FileLogBackend(
           kHistoryFileName, kLogRotationSize, kLogMaximumRotation));
-  std::string history = "pkgid:" + context_->pkgid.get() + "|mode:" +
+  std::string history = context_->pkgid.get() + "|" +
       GetRequestTypeString(context_->request_type.get());
   if (success)
     history += "|SUCCESS";
index 5220f6b..4f034bc 100644 (file)
@@ -82,19 +82,19 @@ std::string FileLogBackend::GetTimeStamp() {
   time_t seconds = ts.tv_sec;
   struct tm gmt;
   if (!gmtime_r(&seconds, &gmt))
-    return "[]";
+    return "|";
   int32_t miliseconds = ts.tv_nsec / 1000000;
 
   char buf[32];
-  strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &gmt);
+  strftime(buf, sizeof(buf), "%Y%m%d.%H%M%S", &gmt);
   char timestamp[32];
-  snprintf(timestamp, sizeof(timestamp), "[%s.%03d UTC]", buf, miliseconds);
+  snprintf(timestamp, sizeof(timestamp), "%s.%03dUTC|", buf, miliseconds);
 
   return timestamp;
 }
 
 std::string FileLogBackend::GetPid() {
-  return "[" + std::to_string(getpid()) + "]";
+  return std::to_string(getpid()) + "|";
 }
 
 }  // namespace utils