23#include <IceUtil/Time.h>
32 formatTime(Ice::Long timeMicroSeconds)
34 IceUtil::Time time = IceUtil::Time::microSeconds(timeMicroSeconds);
35 std::string timeStr = time.toDateTime();
36 const auto spacePos = timeStr.find(
' ');
37 if (spacePos != std::string::npos)
39 timeStr = timeStr.substr(spacePos);
41 return QString::fromStdString(timeStr);
47 buildDisplayMessage(
const LogMessage& entry,
int& lineCount)
49 QString whatStr = entry.backtrace.empty()
50 ? QString::fromStdString(entry.what)
51 : QString::fromStdString(entry.what +
"\nBacktrace:\n...");
53 constexpr int maxLinesToShow = 50;
56 for (
int i = 0; i < whatStr.length(); i++)
58 if (whatStr.at(i) ==
'\n')
62 if (lines == maxLinesToShow)
68 if (lines >= maxLinesToShow)
70 whatStr.truncate(pos);
74 lineCount = whatStr.count(
'\n') + 1;
92 entries.push_back(std::move(entry));
99 if (maxEntries == 0 || entries.size() <= maxEntries)
104 const std::size_t removeCount = entries.size() - maxEntries;
105 entries.erase(entries.begin(), entries.begin() + removeCount);
106 first += removeCount;
119 return first + entries.size();
125 return seq >= first && seq <
endSeq();
131 return entries[seq - first];
137 return entries.size();
LogSeq append(const LogMessage &message)
Append message, deriving its display data, and return its sequence number.
LogSeq firstSeq() const
Sequence number of the oldest retained entry.
bool trim()
Drop the oldest entries until the bound is met.
LogSeq endSeq() const
One past the sequence number of the newest retained entry.
const StoredLogEntry & at(LogSeq seq) const
Only valid if contains(seq).
bool contains(LogSeq seq) const
void clear()
Drop everything.
LogStore(std::size_t maxEntries)
This file offers overloads of toIce() and fromIce() functions for STL container types.
quint64 LogSeq
Identifies a stored log entry for as long as it is retained.
A retained log line: the message plus the display data derived from it.
QString displayMessage
truncated message column (4)
int lineCount
number of display lines in displayMessage
QString timeString
formatted time column (0)