mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
Ref T111, allow to limit entries in log component
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4c8ae06eff
commit
266a418c90
@@ -139,6 +139,25 @@ namespace BlackMisc
|
||||
this->removeIf(&CStatusMessage::getSeverity, CStatusMessage::SeverityInfo);
|
||||
}
|
||||
|
||||
int CStatusMessageList::keepLatest(int estimtatedNumber)
|
||||
{
|
||||
const int oldSize = this->size();
|
||||
if (estimtatedNumber >= oldSize) { return 0; }
|
||||
if (estimtatedNumber < 1)
|
||||
{
|
||||
this->clear();
|
||||
return oldSize;
|
||||
}
|
||||
|
||||
CStatusMessageList copy(*this);
|
||||
copy.sortLatestFirst();
|
||||
const QDateTime ts = copy[estimtatedNumber - 1].getUtcTimestamp();
|
||||
copy = *this; // keep order
|
||||
copy.removeBefore(ts);
|
||||
*this = copy;
|
||||
return oldSize - this->size();
|
||||
}
|
||||
|
||||
CStatusMessage::StatusSeverity CStatusMessageList::worstSeverity() const
|
||||
{
|
||||
CStatusMessage::StatusSeverity s = CStatusMessage::SeverityDebug;
|
||||
|
||||
@@ -97,6 +97,10 @@ namespace BlackMisc
|
||||
//! Remove info and below
|
||||
void removeInfoAndBelow();
|
||||
|
||||
//! Keep latest n status messages
|
||||
//! \remark taking timestamp of n-th oldest messages, deleting all older
|
||||
int keepLatest(int estimtatedNumber);
|
||||
|
||||
//! Find worst severity
|
||||
CStatusMessage::StatusSeverity worstSeverity() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user