summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorAsmitha Karunanithi <asmitk01@in.ibm.com>2020-08-02 19:55:21 +0300
committerAsmitha Karunanithi <asmitk01@in.ibm.com>2020-08-04 07:23:09 +0300
commit9c620e21b69ec7c971f12a99a570f8ddb2cf4f63 (patch)
tree139449b869053aac59313ec5105a53dfbc6d7921 /redfish-core
parent96330b9965034bacf1f676c8f049f273db82cc14 (diff)
downloadbmcweb-9c620e21b69ec7c971f12a99a570f8ddb2cf4f63.tar.xz
Removing getTimestampStr method
The method 'getTimestampStr' is not used elsewhere in the code, hence it is removed and replaced by 'crow::utility::getDateTime' method. Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I094fe8ca741bf36755a722e72fadd14ed8df7287
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/log_services.hpp34
1 files changed, 6 insertions, 28 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index bee1a926bb..070737174e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -179,28 +179,6 @@ static int getJournalMetadata(sd_journal* journal,
return ret;
}
-static bool getTimestampStr(const uint64_t usecSinceEpoch,
- std::string& entryTimestamp)
-{
- time_t t = static_cast<time_t>(usecSinceEpoch / 1000 / 1000);
- struct tm* loctime = localtime(&t);
- char entryTime[64] = {};
- if (nullptr != loctime)
- {
- strftime(entryTime, sizeof(entryTime), "%FT%T%z", loctime);
- }
- // Insert the ':' into the timezone
- std::string_view t1(entryTime);
- std::string_view t2(entryTime);
- if (t1.size() > 2 && t2.size() > 2)
- {
- t1.remove_suffix(2);
- t2.remove_prefix(t2.size() - 2);
- }
- entryTimestamp = std::string(t1) + ":" + std::string(t2);
- return true;
-}
-
static bool getEntryTimestamp(sd_journal* journal, std::string& entryTimestamp)
{
int ret = 0;
@@ -212,7 +190,9 @@ static bool getEntryTimestamp(sd_journal* journal, std::string& entryTimestamp)
<< strerror(-ret);
return false;
}
- return getTimestampStr(timestamp, entryTimestamp);
+ entryTimestamp = crow::utility::getDateTime(
+ static_cast<std::time_t>(timestamp / 1000 / 1000));
+ return true;
}
static bool getSkipParam(crow::Response& res, const crow::Request& req,
@@ -3201,10 +3181,8 @@ static void fillPostCodeEntry(
// Get the Created time from the timestamp
std::string entryTimeStr;
- if (!getTimestampStr(usecSinceEpoch, entryTimeStr))
- {
- continue;
- }
+ entryTimeStr = crow::utility::getDateTime(
+ static_cast<std::time_t>(usecSinceEpoch / 1000 / 1000));
// assemble messageArgs: BootIndex, TimeOffset(100us), PostCode(hex)
std::ostringstream hexCode;
@@ -3262,7 +3240,7 @@ static void fillPostCodeEntry(
{"MessageArgs", std::move(messageArgs)},
{"EntryType", "Event"},
{"Severity", std::move(severity)},
- {"Created", std::move(entryTimeStr)}};
+ {"Created", entryTimeStr}};
}
}