summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-07-24 15:28:08 -0500
committerMatt Spinler <spinler@us.ibm.com>2019-08-05 12:49:54 -0500
commitb60e7559cf72fd42cc860101167f02335641ba90 (patch)
tree8f606dff132056a48a89e830f5cbb33e5e48b13b
parent2813f36ded0fce084df9620c972469dc8e096179 (diff)
downloadphosphor-logging-b60e7559cf72fd42cc860101167f02335641ba90.tar.gz
phosphor-logging-b60e7559cf72fd42cc860101167f02335641ba90.zip
Factor out log creation code common code.
In preparation for adding another function to create a log entry, factor out some common code into a new function that will be able to be called in both spots. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I8881f4ec0d36a2b2e2b1897b63d524022a328286
-rw-r--r--log_manager.cpp43
-rw-r--r--log_manager.hpp10
2 files changed, 34 insertions, 19 deletions
diff --git a/log_manager.cpp b/log_manager.cpp
index 0f4e57c..2920546 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -79,24 +79,6 @@ void Manager::commitWithLvl(uint64_t transactionId, std::string errMsg,
void Manager::_commit(uint64_t transactionId, std::string&& errMsg,
Entry::Level errLvl)
{
- if (!Extensions::disableDefaultLogCaps())
- {
- if (errLvl < Entry::sevLowerLimit)
- {
- if (realErrors.size() >= ERROR_CAP)
- {
- erase(realErrors.front());
- }
- }
- else
- {
- if (infoErrors.size() >= ERROR_INFO_CAP)
- {
- erase(infoErrors.front());
- }
- }
- }
-
constexpr const auto transactionIdVar = "TRANSACTION_ID";
// Length of 'TRANSACTION_ID' string.
constexpr const auto transactionIdVarSize = std::strlen(transactionIdVar);
@@ -199,7 +181,30 @@ void Manager::_commit(uint64_t transactionId, std::string&& errMsg,
sd_journal_close(j);
- // Create error Entry dbus object
+ createEntry(errMsg, errLvl, additionalData);
+}
+
+void Manager::createEntry(std::string errMsg, Entry::Level errLvl,
+ std::vector<std::string> additionalData)
+{
+ if (!Extensions::disableDefaultLogCaps())
+ {
+ if (errLvl < Entry::sevLowerLimit)
+ {
+ if (realErrors.size() >= ERROR_CAP)
+ {
+ erase(realErrors.front());
+ }
+ }
+ else
+ {
+ if (infoErrors.size() >= ERROR_INFO_CAP)
+ {
+ erase(infoErrors.front());
+ }
+ }
+ }
+
entryId++;
if (errLvl >= Entry::sevLowerLimit)
{
diff --git a/log_manager.hpp b/log_manager.hpp
index baf6812..15dd3af 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -167,6 +167,16 @@ class Manager : public details::ServerObject<details::ManagerIface>
*/
void doExtensionLogCreate(const Entry& entry);
+ /** @brief Common wrapper for creating an Entry object
+ *
+ * @param[in] errMsg - The error exception message associated with the
+ * error log to be committed.
+ * @param[in] errLvl - level of the error
+ * @param[in] additionalData - The AdditionalData property for the error
+ */
+ void createEntry(std::string errMsg, Entry::Level errLvl,
+ std::vector<std::string> additionalData);
+
/** @brief Persistent sdbusplus DBus bus connection. */
sdbusplus::bus::bus& busLog;
OpenPOWER on IntegriCloud