Print version at history log 98/256998/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 14 Apr 2021 10:35:37 +0000 (19:35 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 26 Apr 2021 08:21:25 +0000 (17:21 +0900)
Change-Id: Ic8aba0517c79a2f2eaeb1c90637c3f22a9239467
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/history_logger.cc
src/common/history_logger.h
src/common/installer/app_installer.cc
src/common/installer/app_installer.h

index 263dcc6..2e3c5be 100644 (file)
@@ -26,12 +26,13 @@ HistoryLogger::HistoryLogger() : started_(false) {
 }
 
 void HistoryLogger::LogHistoryStart(const std::string& pkgid,
-    RequestType type) {
+    const std::string& version, RequestType type) {
   if (started_)
     return;
 
   HistoryBuilder builder;
-  builder.Append(pkgid).Append(GetRequestTypeString(type)).Append("START");
+  builder.Append(pkgid).Append(version).Append(GetRequestTypeString(type)).
+      Append("START");
   backend_->WriteLog(::utils::LogLevel::LOG_INFO, "", builder.Build());
   backend_->WriteLogToFile();
 
@@ -39,9 +40,9 @@ void HistoryLogger::LogHistoryStart(const std::string& pkgid,
 }
 
 void HistoryLogger::LogHistoryEnd(const std::string& pkgid,
-    RequestType type, bool success) {
+    const std::string& version, RequestType type, bool success) {
   HistoryBuilder builder;
-  builder.Append(pkgid).Append(GetRequestTypeString(type));
+  builder.Append(pkgid).Append(version).Append(GetRequestTypeString(type));
   if (success)
     builder.Append("SUCCESS");
   else
index f30cc90..c1e1840 100644 (file)
@@ -22,8 +22,10 @@ class HistoryLogger {
  public:
   HistoryLogger();
   ~HistoryLogger() {}
-  void LogHistoryStart(const std::string& pkgid, RequestType type);
-  void LogHistoryEnd(const std::string& pkgid, RequestType type, bool success);
+  void LogHistoryStart(const std::string& pkgid, const std::string& version,
+      RequestType type);
+  void LogHistoryEnd(const std::string& pkgid, const std::string& version,
+      RequestType type, bool success);
 
  private:
   class HistoryBuilder {
index 905021a..cd8df73 100644 (file)
@@ -248,7 +248,7 @@ AppInstaller::Result AppInstaller::Process() {
     }
     if (!context_->pkgid.get().empty())
       history_logger_.LogHistoryStart(context_->pkgid.get(),
-          context_->request_type.get());
+          GetPackageVersion(), context_->request_type.get());
     SendProgress(current_step * kProgressRange / total_steps);
   }
 
@@ -277,7 +277,7 @@ AppInstaller::Result AppInstaller::Undo() {
   SendFinished(status_);
 
   history_logger_.LogHistoryEnd(context_->pkgid.get(),
-      context_->request_type.get(), false);
+      GetPackageVersion(), context_->request_type.get(), false);
 
   return result_;
 }
@@ -303,7 +303,7 @@ AppInstaller::Result AppInstaller::Clean() {
   SendFinished(status_);
 
   history_logger_.LogHistoryEnd(context_->pkgid.get(),
-      context_->request_type.get(), true);
+      GetPackageVersion(), context_->request_type.get(), true);
 
   return result_;
 }
@@ -817,6 +817,18 @@ void AppInstaller::HandleStepError(Step::Status result,
                  context_->pkgid.get());
 }
 
+std::string AppInstaller::GetPackageVersion() {
+  std::string version;
+  if (context_->manifest_data.get()) {
+    version = context_->manifest_data.get()->version ?
+        context_->manifest_data.get()->version : "";
+  } else {
+    PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
+    version = pkg_query.Version();
+  }
+  return version;
+}
+
 bool AppInstaller::SendStartIfNotSent(bool is_skippable) {
   if (!pi_)
     return false;
index 62ef0a0..086f579 100644 (file)
@@ -299,6 +299,7 @@ class AppInstaller {
                            Step::Status (Step::*method)(),
                            std::string name);
   void HandleStepError(Step::Status result, const std::string& error);
+  std::string GetPackageVersion();
 
   std::shared_ptr<utils::FileLogBackend> failure_logger_;
   Step::Status status_;