summaryrefslogtreecommitdiffstats
path: root/log_manager.cpp
diff options
context:
space:
mode:
authorNagaraju Goruganti <ngorugan@in.ibm.com>2017-10-13 08:09:52 -0500
committerNagaraju Goruganti <ngorugan@in.ibm.com>2017-10-24 10:02:36 -0500
commitf8a5a7978355ead2d148c3e93607d1c24adf8a74 (patch)
treef9e0e7a5ce47f8d0192db1505ab846e379af0807 /log_manager.cpp
parentb0562c48b100bd6478d2d3ce5579d4f7bc7ea168 (diff)
downloadphosphor-logging-f8a5a7978355ead2d148c3e93607d1c24adf8a74.tar.gz
phosphor-logging-f8a5a7978355ead2d148c3e93607d1c24adf8a74.zip
Handle more than 100 error logs
Added new Cap for info(and below) severity errors, if cap size reaches, next commited error of severity:info(and below) will replace the first entry of severity:info(and below). Resolves openbmc/openbmc#2381 Change-Id: I2e56c28a934bf3139e57b36d252bd5ad3e1dd90f Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
Diffstat (limited to 'log_manager.cpp')
-rw-r--r--log_manager.cpp63
1 files changed, 46 insertions, 17 deletions
diff --git a/log_manager.cpp b/log_manager.cpp
index 1efec9c..bd36d66 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -27,19 +27,37 @@ namespace internal
{
void Manager::commit(uint64_t transactionId, std::string errMsg)
{
- if (capped)
+ auto reqLevel = level::ERR; // Default to ERR
+ size_t realErrCnt = entries.size() - infoErrors.size();
+ auto levelmap = g_errLevelMap.find(errMsg);
+
+ if (levelmap != g_errLevelMap.end())
{
- return;
+ reqLevel = levelmap->second;
}
- if (entries.size() >= ERROR_CAP)
+
+ if (static_cast<Entry::Level>(reqLevel) < Entry::sevLowerLimit)
{
- log<level::ERR>("Reached error cap, Ignoring error",
- entry("SIZE=%d", entries.size()),
- entry("ERROR_CAP=%d", ERROR_CAP));
- capped = true;
- return;
+ if (capped)
+ {
+ return;
+ }
+ if (realErrCnt >= ERROR_CAP)
+ {
+ log<level::ERR>("Reached error cap, Ignoring error",
+ entry("SIZE=%d", realErrCnt),
+ entry("ERROR_CAP=%d", ERROR_CAP));
+ capped = true;
+ return;
+ }
+ }
+ 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 = strlen(transactionIdVar);
@@ -149,6 +167,10 @@ void Manager::commit(uint64_t transactionId, std::string errMsg)
// Create error Entry dbus object
entryId++;
+ if (static_cast<Entry::Level>(reqLevel) >= Entry::sevLowerLimit)
+ {
+ infoErrors.push_back(entryId);
+ }
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
auto objPath = std::string(OBJ_ENTRY) + '/' +
@@ -157,12 +179,6 @@ void Manager::commit(uint64_t transactionId, std::string errMsg)
AssociationList objects {};
processMetadata(errMsg, additionalData, objects);
- level reqLevel = level::ERR; // Default to ERR
- auto levelmap = g_errLevelMap.find(errMsg);
- if (levelmap != g_errLevelMap.end())
- {
- reqLevel = levelmap->second;
- }
auto e = std::make_unique<Entry>(
busLog,
objPath,
@@ -208,11 +224,20 @@ void Manager::erase(uint32_t entryId)
fs::path errorPath(ERRLOG_PERSIST_PATH);
errorPath /= std::to_string(id);
fs::remove(errorPath);
-
+ if (entry->second->severity() >= Entry::sevLowerLimit)
+ {
+ auto it = std::find(infoErrors.begin(), infoErrors.end(), entryId);
+ if (it != infoErrors.end())
+ {
+ infoErrors.erase(it);
+ }
+ }
entries.erase(entry);
}
- if (entries.size() < ERROR_CAP)
+ size_t realErrCnt = entries.size() - infoErrors.size();
+
+ if (realErrCnt < ERROR_CAP)
{
capped = false;
}
@@ -240,6 +265,10 @@ void Manager::restore()
if (deserialize(file.path(), *e))
{
e->emit_object_added();
+ if (e->severity() >= Entry::sevLowerLimit)
+ {
+ infoErrors.push_back(idNum);
+ }
entries.insert(std::make_pair(idNum, std::move(e)));
errorIds.push_back(idNum);
}
OpenPOWER on IntegriCloud