Log on for osp-installer command.
authorDongeup Ham <dongeup.ham@samsung.com>
Thu, 2 May 2013 06:41:19 +0000 (15:41 +0900)
committerDongeup Ham <dongeup.ham@samsung.com>
Thu, 2 May 2013 06:41:19 +0000 (15:41 +0900)
Change-Id: Idcfc43fbae2a7cf5c04a186b0c6cbb89fe163951
Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
inc/InstallerDefs.h
src/Manager/InstallerManager.cpp
src/Manager/InstallerManager.h
src/Util/InstallerUtil.cpp

index cb10013..dea3863 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130502.4]"
+#define OSP_INSTALLER_VERSION "version=[20130502.5]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
@@ -89,6 +89,7 @@
 #define TERMINATE_RETRY_COUNT  300
 
 #define DIR_OSP_APPLICATIONS_TEMP                              L"/opt/usr/apps/__@@osp_tmp@@__"
+#define DIR_INSTALL_LOGS                                               L"/opt/usr/apps/logs"
 
 #define DIR_RO_PACKAGE_SYSTEM_MANIFEST                 L"/usr/share/packages/%ls.xml"
 #define DIR_RW_PACKAGE_SYSTEM_MANIFEST                 L"/opt/share/packages/%ls.xml"
index 7084155..91e722d 100755 (executable)
@@ -59,6 +59,7 @@ InstallerManager::InstallerManager(void)
 ,__startTick(0)
 ,__endTick(0)
 ,__isFileLogOn(false)
+,__isHistoryFileLogOn(false)
 {
 }
 
@@ -105,6 +106,36 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In
 
                        __isFileLogOn = true;
                }
+
+               if (File::IsFileExist(DIR_INSTALL_LOGS) == false)
+               {
+                       r = Directory::Create(DIR_INSTALL_LOGS, false);
+                       if (IsFailed(r))
+                       {
+                               // logs
+                       }
+               }
+
+               String logPath = path;
+               String logId;
+               int length = logPath.GetLength();
+               if (logPath.EndsWith("/") == true)
+               {
+                       logPath.Remove(length - 1, 1);
+                       length--;
+               }
+               logPath.SubString(length - PACKAGE_ID_LENGTH, PACKAGE_ID_LENGTH, logId);
+               AppLog("logPath = [%ls], logId = [%ls]", __historyLogFilePath.GetPointer(), logId.GetPointer());
+
+               __historyLogFilePath = DIR_INSTALL_LOGS;
+               __historyLogFilePath += L"/";
+               __historyLogFilePath += logId;
+               __historyLogFilePath += L".txt";
+               InstallerUtil::CreateLog(__historyLogFilePath);
+
+               AppLog("__historyLogFilePath = [%ls]", __historyLogFilePath.GetPointer());
+
+               __isHistoryFileLogOn = true;
        }
 
        AppLog("------------------------------------------");
@@ -839,6 +870,12 @@ InstallerManager::GetLogFilePath() const
        return __logFilePath;
 }
 
+String
+InstallerManager::GetHistoryLogFilePath() const
+{
+       return __historyLogFilePath;
+}
+
 bool
 InstallerManager::IsFileLogOn() const
 {
@@ -846,6 +883,12 @@ InstallerManager::IsFileLogOn() const
 }
 
 bool
+InstallerManager::IsHistoryFileLogOn() const
+{
+       return __isHistoryFileLogOn;
+}
+
+bool
 InstallerManager::SendEvent(InstallationContext* pContext, const PackageId& packageId, const String& key, const String& val)
 {
        TryReturn(pContext, false, "pContext is null.");
index 5d3f174..cc537cd 100755 (executable)
@@ -56,7 +56,9 @@ public:
        InstallerOperation GetInstallerOperation(void) const;
 
        Tizen::Base::String GetLogFilePath() const;
+       Tizen::Base::String GetHistoryLogFilePath() const;
        bool IsFileLogOn() const;
+       bool IsHistoryFileLogOn() const;
 
        static bool SendEvent(InstallationContext* pContext, const Tizen::App::PackageId& packageId, const Tizen::Base::String& key, const Tizen::Base::String& val);
 
@@ -102,7 +104,9 @@ private:
        long long __startTick;
        long long __endTick;
        Tizen::Base::String __logFilePath;
+       Tizen::Base::String __historyLogFilePath;
        bool __isFileLogOn;
+       bool __isHistoryFileLogOn;
 
 }; // InstallerManager
 
index 8970b6e..80fdefa 100755 (executable)
@@ -656,6 +656,22 @@ InstallerUtil::AppendLog(const char* pFunction, int lineNumber, bool fatal, cons
                va_end(args);
                return false;
        }
+
+       if (pManager->IsHistoryFileLogOn() == true)
+       {
+               File historyLogFile;
+               String historyLogFilePath = pManager->GetHistoryLogFilePath();
+               r = historyLogFile.Construct(historyLogFilePath, "a");
+               if (!IsFailed(r))
+               {
+                       r = historyLogFile.Write(logs2, length+1);
+                       if (!IsFailed(r))
+                       {
+                               // success
+                       }
+               }
+       }
+
        va_end(args);
 
        return true;