143 lines
4.1 KiB
Diff
Executable File
143 lines
4.1 KiB
Diff
Executable File
From e1dd95b374504a2a25c18291b640745a12957ace Mon Sep 17 00:00:00 2001
|
|
From: "Wang.Bin" <Bin-B.Wang@luxshare-ict.com>
|
|
Date: Mon, 6 Jan 2025 15:06:13 +0800
|
|
Subject: [PATCH 2/2] Remove-realErrors-and-infoErrors
|
|
|
|
---
|
|
log_manager.cpp | 57 +++++--------------------------------------------
|
|
log_manager.hpp | 16 --------------
|
|
2 files changed, 5 insertions(+), 68 deletions(-)
|
|
|
|
diff --git a/log_manager.cpp b/log_manager.cpp
|
|
index 2bfab30..15be9cb 100644
|
|
--- a/log_manager.cpp
|
|
+++ b/log_manager.cpp
|
|
@@ -55,15 +55,7 @@ inline auto getLevel(const std::string& errMsg)
|
|
return reqLevel;
|
|
}
|
|
|
|
-int Manager::getRealErrSize()
|
|
-{
|
|
- return realErrors.size();
|
|
-}
|
|
|
|
-int Manager::getInfoErrSize()
|
|
-{
|
|
- return infoErrors.size();
|
|
-}
|
|
|
|
uint32_t Manager::commit(uint64_t transactionId, std::string errMsg)
|
|
{
|
|
@@ -200,31 +192,16 @@ void Manager::createEntry(std::string errMsg, Entry::Level errLvl,
|
|
{
|
|
if (!Extensions::disableDefaultLogCaps())
|
|
{
|
|
- if (errLvl < Entry::sevLowerLimit)
|
|
- {
|
|
- if (realErrors.size() >= ERROR_CAP)
|
|
- {
|
|
- erase(realErrors.front());
|
|
- }
|
|
- }
|
|
- else
|
|
+ std::cout << "entries size" << static_cast<int>(entries.size()) <<std::endl;
|
|
+ if (entries.size() >= ERROR_INFO_CAP)
|
|
{
|
|
- if (infoErrors.size() >= ERROR_INFO_CAP)
|
|
- {
|
|
- erase(infoErrors.front());
|
|
- }
|
|
+ erase(entries.begin()->first);
|
|
}
|
|
}
|
|
|
|
+ std::cout << "entryId" << static_cast<int>(entryId)<< std::endl;
|
|
entryId++;
|
|
- if (errLvl >= Entry::sevLowerLimit)
|
|
- {
|
|
- 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();
|
|
@@ -529,21 +506,6 @@ void Manager::erase(uint32_t entryId)
|
|
errorPath /= std::to_string(entryId);
|
|
fs::remove(errorPath);
|
|
|
|
- auto removeId = [](std::list<uint32_t>& ids, uint32_t id) {
|
|
- auto it = std::find(ids.begin(), ids.end(), id);
|
|
- if (it != ids.end())
|
|
- {
|
|
- ids.erase(it);
|
|
- }
|
|
- };
|
|
- if (entryFound->second->severity() >= Entry::sevLowerLimit)
|
|
- {
|
|
- removeId(infoErrors, entryId);
|
|
- }
|
|
- else
|
|
- {
|
|
- removeId(realErrors, entryId);
|
|
- }
|
|
entries.erase(entryFound);
|
|
|
|
checkAndRemoveBlockingError(entryId);
|
|
@@ -592,15 +554,6 @@ void Manager::restore()
|
|
if (sanity(static_cast<uint32_t>(idNum), e->id()))
|
|
{
|
|
e->path(file.path(), true);
|
|
- if (e->severity() >= Entry::sevLowerLimit)
|
|
- {
|
|
- infoErrors.push_back(idNum);
|
|
- }
|
|
- else
|
|
- {
|
|
- realErrors.push_back(idNum);
|
|
- }
|
|
-
|
|
entries.insert(std::make_pair(idNum, std::move(e)));
|
|
}
|
|
else
|
|
diff --git a/log_manager.hpp b/log_manager.hpp
|
|
index 0b9056f..80866a7 100644
|
|
--- a/log_manager.hpp
|
|
+++ b/log_manager.hpp
|
|
@@ -124,17 +124,6 @@ class Manager : public details::ServerObject<details::ManagerIface>
|
|
entryId = 0;
|
|
}
|
|
|
|
- /** @brief Returns the count of high severity errors
|
|
- *
|
|
- * @return int - count of real errors
|
|
- */
|
|
- int getRealErrSize();
|
|
-
|
|
- /** @brief Returns the count of Info errors
|
|
- *
|
|
- * @return int - count of info errors
|
|
- */
|
|
- int getInfoErrSize();
|
|
|
|
/** @brief Returns the number of blocking errors
|
|
*
|
|
@@ -325,11 +314,6 @@ class Manager : public details::ServerObject<details::ManagerIface>
|
|
/** @brief Persistent sdbusplus DBus bus connection. */
|
|
sdbusplus::bus_t& busLog;
|
|
|
|
- /** @brief List of error ids for high severity errors */
|
|
- std::list<uint32_t> realErrors;
|
|
-
|
|
- /** @brief List of error ids for Info(and below) severity */
|
|
- std::list<uint32_t> infoErrors;
|
|
|
|
/** @brief Id of last error log entry */
|
|
uint32_t entryId;
|
|
--
|
|
2.25.1
|
|
|