STEP_NAME marco 27/72827/4
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 2 Jun 2016 12:55:26 +0000 (14:55 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Fri, 3 Jun 2016 09:45:58 +0000 (02:45 -0700)
Adding marco to print name of step that failed
in AppInstaller class

Following must be submitted together:
 - https://review.tizen.org/gerrit/72827
 - https://review.tizen.org/gerrit/72828
 - https://review.tizen.org/gerrit/72829

Change-Id: I6dcaa9b797836b3e6adde082513aba240fa1040b

54 files changed:
src/common/app_installer.cc
src/common/step/backup/step_backup_icons.h
src/common/step/backup/step_backup_manifest.h
src/common/step/backup/step_copy_backup.h
src/common/step/configuration/step_block_cross_update.h
src/common/step/configuration/step_check_tizen_version.h
src/common/step/configuration/step_configure.h
src/common/step/configuration/step_fail.h
src/common/step/configuration/step_parse_manifest.h
src/common/step/filesystem/step_acquire_external_storage.h
src/common/step/filesystem/step_clear_data.h
src/common/step/filesystem/step_copy.h
src/common/step/filesystem/step_copy_storage_directories.h
src/common/step/filesystem/step_copy_tep.h
src/common/step/filesystem/step_create_icons.h
src/common/step/filesystem/step_create_per_user_storage_directories.h
src/common/step/filesystem/step_create_storage_directories.h
src/common/step/filesystem/step_delta_patch.h
src/common/step/filesystem/step_recover_external_storage.h
src/common/step/filesystem/step_recover_files.h
src/common/step/filesystem/step_recover_icons.h
src/common/step/filesystem/step_recover_manifest.h
src/common/step/filesystem/step_recover_storage_directories.h
src/common/step/filesystem/step_remove_files.h
src/common/step/filesystem/step_remove_icons.h
src/common/step/filesystem/step_remove_per_user_storage_directories.h
src/common/step/filesystem/step_remove_temporary_directory.h
src/common/step/filesystem/step_remove_zip_image.h
src/common/step/filesystem/step_unzip.h
src/common/step/mount/step_mount_install.h
src/common/step/mount/step_mount_unpacked.h
src/common/step/mount/step_mount_update.h
src/common/step/pkgmgr/step_check_removable.h
src/common/step/pkgmgr/step_kill_apps.h
src/common/step/pkgmgr/step_recover_application.h
src/common/step/pkgmgr/step_register_app.h
src/common/step/pkgmgr/step_remove_manifest.h
src/common/step/pkgmgr/step_run_parser_plugins.h
src/common/step/pkgmgr/step_unregister_app.h
src/common/step/pkgmgr/step_update_app.h
src/common/step/pkgmgr/step_update_tep.h
src/common/step/rds/step_rds_parse.h
src/common/step/recovery/step_open_recovery_file.h
src/common/step/security/step_check_background_category.h
src/common/step/security/step_check_old_certificate.h
src/common/step/security/step_check_signature.h
src/common/step/security/step_privilege_compatibility.h
src/common/step/security/step_recover_security.h
src/common/step/security/step_register_security.h
src/common/step/security/step_revoke_security.h
src/common/step/security/step_rollback_deinstallation_security.h
src/common/step/security/step_rollback_installation_security.h
src/common/step/security/step_update_security.h
src/common/step/step.h

index 5d58c66..ec5f84d 100644 (file)
@@ -48,11 +48,18 @@ AppInstaller::Result AppInstaller::Run() {
   for (; it != itEnd; ++it, ++current_step) {
     try {
       process_status = (*it)->precheck();
+    } catch (const std::exception& err) {
+      LOG(ERROR) << "Exception occurred in precheck(): " << err.what()
+                 << " in step: " << (*it)->name();
+      process_status = Step::Status::ERROR;
+    }
+    try {
       if (process_status == Step::Status::OK) {
         process_status = (*it)->process();
       }
     } catch (const std::exception& err) {
-      LOG(ERROR) << "Exception occurred in process(): " << err.what();
+      LOG(ERROR) << "Exception occurred in process(): " << err.what()
+                 << " in step: " << (*it)->name();
       process_status = Step::Status::ERROR;
     }
 
@@ -86,7 +93,8 @@ AppInstaller::Result AppInstaller::Run() {
           ret = Result::UNDO_ERROR;
         }
       } catch (const std::exception& err) {
-        LOG(ERROR) << "Exception occurred in undo(): " << err.what();
+        LOG(ERROR) << "Exception occurred in undo(): " << err.what()
+                   << " in step: " << (*it)->name();
         ret = Result::UNDO_ERROR;
       }
     } while (it-- != itStart);
@@ -99,7 +107,8 @@ AppInstaller::Result AppInstaller::Run() {
           break;
         }
       } catch (const std::exception& err) {
-        LOG(ERROR) << "Exception occurred in clean(): " << err.what();
+        LOG(ERROR) << "Exception occurred in clean(): " << err.what()
+                   << " in step: " << step->name();
         ret = Result::CLEANUP_ERROR;
         break;
       }
index 843c916..80e36f5 100644 (file)
@@ -53,7 +53,7 @@ class StepBackupIcons : public Step {
   std::vector<std::pair<boost::filesystem::path, boost::filesystem::path>>
       icons_;
 
-  SCOPE_LOG_TAG(BackupIcons)
+  STEP_NAME(BackupIcons)
 };
 
 }  // namespace backup
index 59980a2..bafceb6 100644 (file)
@@ -44,7 +44,7 @@ class StepBackupManifest : public Step {
 
   Status precheck() override;
 
-  SCOPE_LOG_TAG(BackupManifest)
+  STEP_NAME(BackupManifest)
 };
 
 }  // namespace backup
index fea81c0..a4ed590 100644 (file)
@@ -63,7 +63,7 @@ class StepCopyBackup : public Step {
   boost::filesystem::path install_path_;
   boost::filesystem::path backup_path_;
 
-  SCOPE_LOG_TAG(CopyBackup)
+  STEP_NAME(CopyBackup)
 };
 
 }  // namespace backup
index cc32e8d..147b562 100644 (file)
@@ -35,7 +35,7 @@ class StepBlockCrossUpdate : public Step {
   Status undo() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(BlockCrossUpdate)
+  STEP_NAME(BlockCrossUpdate)
 };
 
 }  // namespace configuration
index 82cdb90..efa5368 100644 (file)
@@ -21,7 +21,7 @@ class StepCheckTizenVersion : public Step {
   Status undo() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(CheckTizenVersion)
+  STEP_NAME(CheckTizenVersion)
 };
 
 }  // namespace configuration
index 902fc0d..2041344 100644 (file)
@@ -64,7 +64,7 @@ class StepConfigure : public Step {
 
   PkgMgrPtr pkgmgr_;
 
-  SCOPE_LOG_TAG(Configure)
+  STEP_NAME(Configure)
 };
 
 }  // namespace configuration
index d3a50c6..b51023e 100644 (file)
@@ -32,7 +32,7 @@ class StepFail : public Step {
   Status undo() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(Fail)
+  STEP_NAME(Fail)
 };
 
 }  // namespace configuration
index be509a3..bd72285 100644 (file)
@@ -98,7 +98,7 @@ class StepParseManifest : public common_installer::Step {
   ManifestLocation manifest_location_;
   StoreLocation store_location_;
 
-  SCOPE_LOG_TAG(ParseManifest)
+  STEP_NAME(ParseManifest)
 };
 
 }  // namespace configuration
index e1e1789..5f583a5 100644 (file)
@@ -26,7 +26,7 @@ class StepAcquireExternalStorage : public Step {
   Status undo() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(AcquireExternalStorage)
+  STEP_NAME(AcquireExternalStorage)
 };
 
 }  // namespace filesystem
index 1696237..16cf013 100644 (file)
@@ -28,7 +28,7 @@ class StepClearData : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(ClearData)
+  STEP_NAME(ClearData)
 };
 
 }  // namespace filesystem
index 598b5c9..d4887d2 100644 (file)
@@ -47,7 +47,7 @@ class StepCopy : public Step {
    */
   Status precheck() override;
 
-  SCOPE_LOG_TAG(Copy)
+  STEP_NAME(Copy)
 };
 
 }  // namespace filesystem
index d7ebc0a..dafd04b 100644 (file)
@@ -51,7 +51,7 @@ class StepCopyStorageDirectories : public common_installer::Step {
                       const char *key, bool merge_dirs = false);
   bool CacheDir();
   boost::filesystem::path backup_path_;
-  SCOPE_LOG_TAG(CopyStorageDirectories)
+  STEP_NAME(CopyStorageDirectories)
 };
 
 }  // namespace filesystem
index 33c70a9..8c65ca7 100644 (file)
@@ -46,7 +46,7 @@ class StepCopyTep : public Step {
    */
   Status precheck() override;
 
-  SCOPE_LOG_TAG(CopyTEP)
+  STEP_NAME(CopyTEP)
 };
 
 }  // namespace filesystem
index 00aa6fa..1e9d0d5 100644 (file)
@@ -45,7 +45,7 @@ class StepCreateIcons : public Step {
  private:
   std::vector<boost::filesystem::path> icons_;
 
-  SCOPE_LOG_TAG(CreateIcons)
+  STEP_NAME(CreateIcons)
 };
 
 }  // namespace filesystem
index 30364ee..4d2a9fc 100644 (file)
@@ -31,7 +31,7 @@ class StepCreatePerUserStorageDirectories : public common_installer::Step {
   Status undo() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(CreatePerUserStorageDirectories)
+  STEP_NAME(CreatePerUserStorageDirectories)
 
  private:
   bool CreateExternalStorageDir();
index cecd0c6..0a523eb 100644 (file)
@@ -40,7 +40,7 @@ class StepCreateStorageDirectories : public common_installer::Step {
   bool PrivateDir();
   bool CacheDir();
 
-  SCOPE_LOG_TAG(CreateStorageDirectories)
+  STEP_NAME(CreateStorageDirectories)
 };
 
 }  // namespace filesystem
index 0f216b3..3bb3688 100644 (file)
@@ -48,7 +48,7 @@ class StepDeltaPatch : public Step {
   boost::filesystem::path patch_dir_;
   std::string delta_root_;
 
-  SCOPE_LOG_TAG(DeltaPatch)
+  STEP_NAME(DeltaPatch)
 };
 
 }  // namespace filesystem
index bc65cec..68bac1b 100644 (file)
@@ -22,7 +22,7 @@ class StepRecoverExternalStorage : public StepAcquireExternalStorage {
 
   Status process() override;
 
-  SCOPE_LOG_TAG(RecoverExternalStorage)
+  STEP_NAME(RecoverExternalStorage)
 };
 
 }  // namespace filesystem
index 90de483..9fc5b96 100644 (file)
@@ -31,7 +31,7 @@ class StepRecoverFiles : public recovery::StepRecovery {
  private:
   bool SetPackagePath();
 
-  SCOPE_LOG_TAG(RecoverBackup)
+  STEP_NAME(RecoverBackup)
 };
 
 }  // namespace filesystem
index 5575307..4e3692e 100644 (file)
@@ -40,7 +40,7 @@ class StepRecoverIcons : public recovery::StepRecovery {
   std::set<std::pair<boost::filesystem::path, boost::filesystem::path>>
       icons_;
 
-  SCOPE_LOG_TAG(RecoverIcons)
+  STEP_NAME(RecoverIcons)
 };
 
 }  // namespace filesystem
index 3e9f400..d53eda4 100644 (file)
@@ -31,7 +31,7 @@ class StepRecoverManifest : public recovery::StepRecovery {
  private:
   bool SetXmlPaths();
 
-  SCOPE_LOG_TAG(RecoverManifest)
+  STEP_NAME(RecoverManifest)
 };
 
 }  // namespace filesystem
index 3fbd696..bc5db7a 100644 (file)
@@ -37,7 +37,7 @@ class StepRecoverStorageDirectories : public recovery::StepRecovery {
                       const boost::filesystem::path& in_dst,
                       const char *key);
 
-  SCOPE_LOG_TAG(RecoverStorageDirectories)
+  STEP_NAME(RecoverStorageDirectories)
 };
 
 }  // namespace filesystem
index 51dda19..44ed784 100644 (file)
@@ -23,7 +23,7 @@ class StepRemoveFiles : public Step {
   Status undo() override  { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(Remove)
+  STEP_NAME(Remove)
 };
 
 }  // namespace filesystem
index 57b92a2..60eb11b 100644 (file)
@@ -27,7 +27,7 @@ class StepRemoveIcons : public Step {
   Status undo() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(RemoveIcons)
+  STEP_NAME(RemoveIcons)
 };
 
 }  // namespace filesystem
index d0a9674..5dcae94 100644 (file)
@@ -33,7 +33,7 @@ class StepRemovePerUserStorageDirectories : public common_installer::Step {
   Status undo() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(RemovePerUserStorageDirectories)
+  STEP_NAME(RemovePerUserStorageDirectories)
 };
 
 }  // namespace filesystem
index 5e1c804..809bd18 100644 (file)
@@ -33,7 +33,7 @@ class StepRemoveTemporaryDirectory : public recovery::StepRecovery {
    */
   void RemoveFiles();
 
-  SCOPE_LOG_TAG(RemoveTemporaryDirectory)
+  STEP_NAME(RemoveTemporaryDirectory)
 };
 
 }  // namespace filesystem
index 91b008e..4775015 100644 (file)
@@ -29,7 +29,7 @@ class StepRemoveZipImage : public Step {
   Status undo() override  { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(RemoveZipImage)
+  STEP_NAME(RemoveZipImage)
 };
 
 }  // namespace filesystem
index aede813..7d9651e 100644 (file)
@@ -38,7 +38,7 @@ class StepUnzip : public Step {
   Status undo() override;
   Status precheck() override;
 
-  SCOPE_LOG_TAG(Unzip)
+  STEP_NAME(Unzip)
 };
 
 }  // namespace filesystem
index 5d37dcc..095e27c 100644 (file)
@@ -35,7 +35,7 @@ class StepMountInstall : public Step {
   Status undo() override;
   Status precheck() override;
 
-  SCOPE_LOG_TAG(MountInstall)
+  STEP_NAME(MountInstall)
 };
 
 }  // namespace mount
index d914275..f123ae2 100644 (file)
@@ -32,7 +32,7 @@ class StepMountUnpacked : public Step {
   Status undo() override;
   Status precheck() override;
 
-  SCOPE_LOG_TAG(MountUnpacked)
+  STEP_NAME(MountUnpacked)
 };
 
 }  // namespace mount
index b374a15..cd02e4d 100644 (file)
@@ -35,7 +35,7 @@ class StepMountUpdate : public Step {
   Status undo() override;
   Status precheck() override;
 
-  SCOPE_LOG_TAG(MountUpdate)
+  STEP_NAME(MountUpdate)
 };
 
 }  // namespace mount
index 18c7fb9..59b190f 100644 (file)
@@ -19,7 +19,7 @@ class StepCheckRemovable : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(CheckRemovable)
+  STEP_NAME(CheckRemovable)
 };
 
 }  // namespace pkgmgr
index d1e9d17..b84f969 100644 (file)
@@ -38,7 +38,7 @@ class StepKillApps : public Step {
    */
   Status precheck() override;
 
-  SCOPE_LOG_TAG(KillApps)
+  STEP_NAME(KillApps)
 };
 
 }  // namespace pkgmgr
index 84e7146..56624a8 100644 (file)
@@ -28,7 +28,7 @@ class StepRecoverApplication : public recovery::StepRecovery {
  private:
   bool SetXmlPaths();
 
-  SCOPE_LOG_TAG(RecoverApplication)
+  STEP_NAME(RecoverApplication)
 };
 
 }  // namespace pkgmgr
index 8387211..965a410 100644 (file)
@@ -20,7 +20,7 @@ class StepRegisterApplication : public Step {
   Status undo() override;
   Status precheck() override;
 
-  SCOPE_LOG_TAG(RegisterApp)
+  STEP_NAME(RegisterApp)
 };
 
 }  // namespace pkgmgr
index 8688cfc..6f19533 100644 (file)
@@ -31,7 +31,7 @@ class StepRemoveManifest : public Step {
   Status undo() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(RemoveManifest)
+  STEP_NAME(RemoveManifest)
 };
 
 }  // namespace pkgmgr
index a547c6d..4b9c41a 100644 (file)
@@ -35,7 +35,7 @@ class StepRunParserPlugin : public Step {
 
   Plugin::ActionType action_type_;
 
-  SCOPE_LOG_TAG(RunParserPlugin)
+  STEP_NAME(RunParserPlugin)
 };
 
 }  // namespace pkgmgr
index 9eeed6c..91ce0f6 100644 (file)
@@ -25,7 +25,7 @@ class StepUnregisterApplication : public Step {
  private:
   bool BackupCertInfo();
 
-  SCOPE_LOG_TAG(Unregister)
+  STEP_NAME(Unregister)
 };
 
 }  // namespace pkgmgr
index 788b2d7..c9008d3 100644 (file)
@@ -22,7 +22,7 @@ class StepUpdateApplication : public Step {
   Status undo() override;
   Status precheck() override;
 
-  SCOPE_LOG_TAG(UpdateApplication)
+  STEP_NAME(UpdateApplication)
 };
 
 }  // namespace pkgmgr
index c00f715..7d19a74 100644 (file)
@@ -25,7 +25,7 @@ class StepUpdateTep : public Step {
   Status undo() override;
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(UpdateTep)
+  STEP_NAME(UpdateTep)
 };
 
 }  // namespace pkgmgr
index 8bbdf49..d676dcc 100644 (file)
@@ -47,6 +47,8 @@ class StepRDSParse : public Step {
 
  private:
   boost::filesystem::path rds_file_path_;
+
+  STEP_NAME(RDSParse)
 };
 
 }  // namespace rds
index dda174d..8c80c12 100644 (file)
@@ -23,7 +23,7 @@ class StepOpenRecoveryFile : public Step {
   Status undo() override;
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(OpenRecoveryFile)
+  STEP_NAME(OpenRecoveryFile)
 };
 
 }  // namespace recovery
index 46e275b..6eb0da4 100644 (file)
@@ -92,7 +92,7 @@ class StepCheckBackgroundCategory : public common_installer::Step {
   const BackgroundCatSet known_background_categories_;
   const BackgroundCatSet not_unknown_background_categories_;
 
-  SCOPE_LOG_TAG(CheckBackgroundCategory)
+  STEP_NAME(CheckBackgroundCategory)
 };
 
 }  // namespace security
index f3c8e12..1cbb72a 100644 (file)
@@ -31,7 +31,7 @@ class StepCheckOldCertificate : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(CheckOldCertificate)
+  STEP_NAME(CheckOldCertificate)
 };
 
 }  // namespace security
index e71671b..ab63df5 100644 (file)
@@ -52,7 +52,7 @@ class StepCheckSignature : public Step {
   Status CheckSignatureMismatch();
   Status CheckPrivilegeLevel(PrivilegeLevel level);
 
-  SCOPE_LOG_TAG(Signature)
+  STEP_NAME(Signature)
 };
 
 }  // namespace security
index 30a0015..83da70e 100644 (file)
@@ -27,7 +27,7 @@ class StepPrivilegeCompatibility : public Step {
   Status undo() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(PrivilegeCompatibility)
+  STEP_NAME(PrivilegeCompatibility)
 };
 
 }  // namespace security
index 429df46..837ea89 100644 (file)
@@ -32,7 +32,7 @@ class StepRecoverSecurity : public recovery::StepRecovery {
  private:
   bool Check();
 
-  SCOPE_LOG_TAG(RecoverSecurity)
+  STEP_NAME(RecoverSecurity)
 };
 
 }  // namespace security
index b4bfb06..d107ef1 100644 (file)
@@ -21,7 +21,7 @@ class StepRegisterSecurity : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(Security)
+  STEP_NAME(Security)
 };
 
 }  // namespace security
index 14645fd..2c27589 100644 (file)
@@ -24,7 +24,7 @@ class StepRevokeSecurity : public Step {
   Status clean() override;
   Status precheck() override;
 
-  SCOPE_LOG_TAG(RevokeSecurity)
+  STEP_NAME(RevokeSecurity)
 };
 
 }  // namespace security
index 3ad3f27..cbca2f0 100644 (file)
@@ -23,7 +23,7 @@ class StepRollbackDeinstallationSecurity : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(RollbackDeinstallationSecurity)
+  STEP_NAME(RollbackDeinstallationSecurity)
 };
 
 }  // namespace security
index 58bd0e1..65408fe 100644 (file)
@@ -24,7 +24,7 @@ class StepRollbackInstallationSecurity : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override;
 
-  SCOPE_LOG_TAG(RollbackInstallationSecurity)
+  STEP_NAME(RollbackInstallationSecurity)
 };
 
 }  // namespace security
index 0578269..6c78e41 100644 (file)
@@ -21,7 +21,7 @@ class StepUpdateSecurity : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
-  SCOPE_LOG_TAG(UpdateSecurity)
+  STEP_NAME(UpdateSecurity)
 };
 
 }  // namespace security
index b072c36..304566b 100644 (file)
 
 #include "common/installer_context.h"
 
+// This macro should be defined at the end of class definition
+#define STEP_NAME(NAME)                                                        \
+  SCOPE_LOG_TAG(NAME)                                                          \
+  const char* name() const override { return #NAME; }                          \
+
 namespace common_installer {
 
 /**
@@ -93,6 +98,9 @@ class Step {
   /** Checks the input data used during process method */
   virtual Status precheck() = 0;
 
+  /** Returns step name */
+  virtual const char* name() const = 0;
+
   StepErrorSignal on_error;
 
  protected: