summaryrefslogtreecommitdiffstats
path: root/log_manager.cpp
diff options
context:
space:
mode:
authorNagaraju Goruganti <ngorugan@in.ibm.com>2017-11-30 02:12:45 -0600
committerNagaraju Goruganti <ngorugan@in.ibm.com>2017-12-01 06:26:40 -0600
commite4b0b77180adc4c2f63e83abbf849f09fd399055 (patch)
treef0f9a1bd84561134dbbdcffc81fe534ab6f94bf4 /log_manager.cpp
parent979ed1cce24fa0cffd4fe414b8a56e17ec032b14 (diff)
downloadphosphor-logging-e4b0b77180adc4c2f63e83abbf849f09fd399055.tar.gz
phosphor-logging-e4b0b77180adc4c2f63e83abbf849f09fd399055.zip
Roll errors after reaching Cap size
Fixes openbmc/openbmc#2687 -cap on error exists to deal with small flashes, right now the cap is 100 for high severity errors and it is 10 for info(and below) severity) errors. -previous policy was to stop logging new errors once cap is reached for high severity errors. -based on feedback from field engineers, it's better to log new errors, external tools will typically periodically read and store errors, so we won't lose them.so the new policy now is to roll errors. Change-Id: I18b509d81c076fcb80667300cbfda050027bb422 Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
Diffstat (limited to 'log_manager.cpp')
-rw-r--r--log_manager.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/log_manager.cpp b/log_manager.cpp
index 0d8e753..cc5e187 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -28,7 +28,6 @@ namespace internal
void Manager::commit(uint64_t transactionId, std::string errMsg)
{
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())
@@ -38,17 +37,9 @@ void Manager::commit(uint64_t transactionId, std::string errMsg)
if (static_cast<Entry::Level>(reqLevel) < Entry::sevLowerLimit)
{
- if (capped)
+ if (realErrors.size() >= ERROR_CAP)
{
- 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;
+ erase(realErrors.front());
}
}
else
@@ -171,6 +162,10 @@ void Manager::commit(uint64_t transactionId, std::string errMsg)
{
infoErrors.push_back(entryId);
}
+ else
+ {
+ realErrors.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) + '/' +
@@ -223,13 +218,22 @@ void Manager::erase(uint32_t entryId)
fs::path errorPath(ERRLOG_PERSIST_PATH);
errorPath /= std::to_string(entryId);
fs::remove(errorPath);
- if (entry->second->severity() >= Entry::sevLowerLimit)
+
+ auto removeId = [](std::list<uint32_t>& ids , uint32_t id)
{
- auto it = std::find(infoErrors.begin(), infoErrors.end(), entryId);
- if (it != infoErrors.end())
+ auto it = std::find(ids.begin(), ids.end(), id);
+ if (it != ids.end())
{
- infoErrors.erase(it);
+ ids.erase(it);
}
+ };
+ if (entry->second->severity() >= Entry::sevLowerLimit)
+ {
+ removeId(infoErrors, entryId);
+ }
+ else
+ {
+ removeId(realErrors, entryId);
}
entries.erase(entry);
}
@@ -238,13 +242,6 @@ void Manager::erase(uint32_t entryId)
logging::log<level::ERR>("Invalid entry ID to delete",
logging::entry("ID=%d", entryId));
}
-
- size_t realErrCnt = entries.size() - infoErrors.size();
-
- if (realErrCnt < ERROR_CAP)
- {
- capped = false;
- }
}
void Manager::restore()
@@ -280,6 +277,10 @@ void Manager::restore()
{
infoErrors.push_back(idNum);
}
+ else
+ {
+ realErrors.push_back(idNum);
+ }
entries.insert(std::make_pair(idNum, std::move(e)));
errorIds.push_back(idNum);
OpenPOWER on IntegriCloud