Fix logging installation history 70/238570/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 15 Jul 2020 07:15:26 +0000 (16:15 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 15 Jul 2020 07:15:26 +0000 (16:15 +0900)
Add additional log when starting installation process.

Change-Id: I29aa5ea082756851d1858c9caf132bee55a02e5b
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/installer/app_installer.cc
src/common/installer/app_installer.h

index c3fcd07..e5636fb 100644 (file)
@@ -219,7 +219,18 @@ AppInstaller::Result AppInstaller::Run() {
   return result_;
 }
 
-void AppInstaller::LogHistory(bool success) {
+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";
+  history_logger->WriteLog(::utils::LogLevel::LOG_INFO, "", history);
+  history_logger->WriteLogToFile();
+}
+
+void AppInstaller::LogHistoryEnd(bool success) {
   std::shared_ptr<utils::FileLogBackend> history_logger =
       std::shared_ptr<utils::FileLogBackend>(new utils::FileLogBackend(
           kHistoryFileName, kLogRotationSize, kLogMaximumRotation));
@@ -283,7 +294,7 @@ AppInstaller::Result AppInstaller::Undo() {
     status_ = Step::Status::ERROR;
   SendFinished(status_);
 
-  LogHistory(false);
+  LogHistoryEnd(false);
 
   return result_;
 }
@@ -308,7 +319,7 @@ AppInstaller::Result AppInstaller::Clean() {
   } while (it_-- != steps_.begin());
   sync();
 
-  LogHistory(true);
+  LogHistoryEnd(true);
 
   return result_;
 }
@@ -835,6 +846,8 @@ bool AppInstaller::SendStartIfNotSent() {
   pi_->SetRequestType(context_->request_type.get());
   pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
 
+  LogHistoryStart();
+
   return true;
 }
 
index ce225de..8996fb8 100644 (file)
@@ -302,7 +302,8 @@ class AppInstaller {
   std::shared_ptr<utils::FileLogBackend> failure_logger_;
   Step::Status status_;
   Result result_;
-  void LogHistory(bool success);
+  void LogHistoryStart();
+  void LogHistoryEnd(bool success);
 
   int index_;