From: Sangyoon Jang Date: Wed, 15 Jul 2020 08:22:28 +0000 (+0900) Subject: Fix file logging format X-Git-Tag: submit/tizen/20200717.052111~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d17c85a499aff0d4dd48d4a60daaf924ca54bbcb;p=platform%2Fcore%2Fappfw%2Fapp-installers.git Fix file logging format Change-Id: I0d505736051b4ad43fedb06bf20790f9fe15e3fd Signed-off-by: Sangyoon Jang --- diff --git a/src/common/installer/app_installer.cc b/src/common/installer/app_installer.cc index e5636fb5..a8d0b6b8 100644 --- a/src/common/installer/app_installer.cc +++ b/src/common/installer/app_installer.cc @@ -223,9 +223,8 @@ void AppInstaller::LogHistoryStart() { std::shared_ptr history_logger = std::shared_ptr(new utils::FileLogBackend( kHistoryFileName, kLogRotationSize, kLogMaximumRotation)); - std::string history = "pkgid:" + context_->pkgid.get() + "|mode:" + - GetRequestTypeString(context_->request_type.get()); - history += "|START"; + std::string history = context_->pkgid.get() + "|" + + GetRequestTypeString(context_->request_type.get()) + "|START"; history_logger->WriteLog(::utils::LogLevel::LOG_INFO, "", history); history_logger->WriteLogToFile(); } @@ -234,7 +233,7 @@ void AppInstaller::LogHistoryEnd(bool success) { std::shared_ptr history_logger = std::shared_ptr(new utils::FileLogBackend( kHistoryFileName, kLogRotationSize, kLogMaximumRotation)); - std::string history = "pkgid:" + context_->pkgid.get() + "|mode:" + + std::string history = context_->pkgid.get() + "|" + GetRequestTypeString(context_->request_type.get()); if (success) history += "|SUCCESS"; diff --git a/src/common/utils/file_logbackend.cc b/src/common/utils/file_logbackend.cc index 5220f6b1..4f034bc0 100644 --- a/src/common/utils/file_logbackend.cc +++ b/src/common/utils/file_logbackend.cc @@ -82,19 +82,19 @@ std::string FileLogBackend::GetTimeStamp() { time_t seconds = ts.tv_sec; struct tm gmt; if (!gmtime_r(&seconds, &gmt)) - return "[]"; + return "|"; int32_t miliseconds = ts.tv_nsec / 1000000; char buf[32]; - strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &gmt); + strftime(buf, sizeof(buf), "%Y%m%d.%H%M%S", &gmt); char timestamp[32]; - snprintf(timestamp, sizeof(timestamp), "[%s.%03d UTC]", buf, miliseconds); + snprintf(timestamp, sizeof(timestamp), "%s.%03dUTC|", buf, miliseconds); return timestamp; } std::string FileLogBackend::GetPid() { - return "[" + std::to_string(getpid()) + "]"; + return std::to_string(getpid()) + "|"; } } // namespace utils