Write log to file when installation process failed 21/207821/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 26 Mar 2019 12:05:32 +0000 (21:05 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 13 Jun 2019 05:33:04 +0000 (05:33 +0000)
When installation process failed, installer will write entire log at
"/var/log/app-installers.log". (except DEBUG level log)

Change-Id: I1d7aee6be3f67d16ff2749405bf28fc14e076cfe
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
(cherry picked from commit 229e5ce1fb30a82fcedfba81a60dfcf70d7c3383)

src/common/app_installer.cc

index 5dbd755..222d44f 100644 (file)
@@ -17,6 +17,9 @@
 namespace {
 
 const unsigned kProgressRange = 100;
+const char kLogFileName[] = "/var/log/app-installers.log";
+const int kLogRotationSize = 1024 * 256;  // 256KB
+const int kLogMaximumRotation = 3;
 
 }
 
@@ -48,6 +51,10 @@ AppInstaller::Result AppInstaller::Run() {
   unsigned total_steps = steps_.size();
   unsigned current_step = 1;
 
+  ::utils::LogCore::GetCore().SetFileName(kLogFileName);
+  ::utils::LogCore::GetCore().SetRotationSize(kLogRotationSize);
+  ::utils::LogCore::GetCore().SetMaximumRotation(kLogMaximumRotation);
+
   for (; it != itEnd; ++it, ++current_step) {
     try {
       TTRACE(TTRACE_TAG_APP, "%s_%s", (*it)->name(), "precheck");
@@ -109,6 +116,7 @@ AppInstaller::Result AppInstaller::Run() {
         ret = Result::UNDO_ERROR;
       }
     } while (it-- != itStart);
+    ::utils::LogCore::GetCore().WriteLog();
   } else {
     if (it == itEnd)
       --it;