| Line |
Branch |
Decision |
Call |
Exec |
Source |
| 1 |
|
|
|
|
#include "LoggerTextEditSink.h" |
| 2 |
|
|
|
|
|
| 3 |
|
|
|
|
#include <QScrollBar> |
| 4 |
|
|
|
|
#include <QRegularExpression> |
| 5 |
|
|
|
|
|
| 6 |
|
|
|
|
#include "Logger.h" |
| 7 |
|
|
|
|
#include "LoggerFormatter.h" |
| 8 |
|
|
|
|
#include "formatters/ColoredLevelFlagFormatter.h" |
| 9 |
|
|
|
|
#include "formatters/ColoredNameFlagFormatter.h" |
| 10 |
|
|
|
|
|
| 11 |
|
|
|
|
using namespace Logging; |
| 12 |
|
|
|
|
using namespace CLO3D::UI; |
| 13 |
|
|
|
|
|
| 14 |
|
|
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
|
✗ |
LoggerTextEditSink::LoggerTextEditSink(QWidget* parent) |
| 15 |
|
|
0/42
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
✗ Call 19 not invoked.
✗ Call 20 not invoked.
✗ Call 21 not invoked.
✗ Call 22 not invoked.
✗ Call 23 not invoked.
✗ Call 24 not invoked.
✗ Call 25 not invoked.
✗ Call 28 not invoked.
✗ Call 31 not invoked.
✗ Call 32 not invoked.
✗ Call 33 not invoked.
✗ Call 34 not invoked.
✗ Call 37 not invoked.
✗ Call 38 not invoked.
✗ Call 39 not invoked.
✗ Call 40 not invoked.
✗ Call 43 not invoked.
✗ Call 44 not invoked.
✗ Call 45 not invoked.
✗ Call 46 not invoked.
✗ Call 47 not invoked.
✗ Call 48 not invoked.
✗ Call 49 not invoked.
✗ Call 50 not invoked.
✗ Call 51 not invoked.
|
✗ |
: QTextEdit(parent), sink_(std::make_shared<spdlog::sinks::qt_sink_mt>(this, FORMAT_METHOD)), cursor_(document()) { |
| 16 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
|
✗ |
setReadOnly(true); |
| 17 |
|
|
|
|
|
| 18 |
|
|
0/11
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
|
✗ |
LoggerFormatter<ColoredNameFlagFormatter, ColoredLevelFlagFormatter>::apply(sink_); |
| 19 |
|
|
|
|
|
| 20 |
|
|
|
|
static constexpr auto FONT_SIZE = 7; |
| 21 |
|
|
|
|
static constexpr auto FONT_FAMILY = "Courier New"; |
| 22 |
|
|
|
|
|
| 23 |
|
|
0/9
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
|
✗ |
QFont font(FONT_FAMILY); |
| 24 |
|
|
0/1
✗ Call 0 not invoked.
|
✗ |
font.setStyleHint(QFont::Monospace); |
| 25 |
|
|
0/1
✗ Call 0 not invoked.
|
✗ |
font.setPointSize(FONT_SIZE); |
| 26 |
|
|
|
|
|
| 27 |
|
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
|
✗ |
defaultFormat_.setFont(font); |
| 28 |
|
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
|
✗ |
coloredFormat_.setFont(font); |
| 29 |
|
|
0/15
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
|
✗ |
} |
| 30 |
|
|
|
|
|
| 31 |
|
|
|
✗ |
void LoggerTextEditSink::attach(Logger* logger) const { |
| 32 |
|
|
0/14
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
|
✗ |
logger->addSink(sink_); |
| 33 |
|
|
|
✗ |
} |
| 34 |
|
|
|
|
|
| 35 |
|
|
|
✗ |
void LoggerTextEditSink::format(const QString& text) { |
| 36 |
|
|
|
|
static constexpr auto ANSI_PATTERN = R"(\x1B\[(\d+(?:;\d+)*)m)"; |
| 37 |
|
|
0/16
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
✗ Call 19 not invoked.
✗ Call 20 not invoked.
✗ Call 21 not invoked.
✗ Call 22 not invoked.
✗ Call 25 not invoked.
|
✗ |
static const QRegularExpression ansiRegex(ANSI_PATTERN); |
| 38 |
|
|
|
|
static const QList palette = { |
| 39 |
|
|
|
|
QColor("#808080"), // 0: black/bright black (trace) |
| 40 |
|
|
|
|
QColor("#f44747"), // 1: red |
| 41 |
|
|
|
|
QColor("#4ec994"), // 2: green |
| 42 |
|
|
|
|
QColor("#ce9178"), // 3: yellow |
| 43 |
|
|
|
|
QColor("#569cd6"), // 4: blue |
| 44 |
|
|
|
|
QColor("#c678dd"), // 5: magenta |
| 45 |
|
|
|
|
QColor("#56b6c2"), // 6: cyan |
| 46 |
|
|
|
|
QColor("#ffffff"), // 7: white |
| 47 |
|
|
0/16
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 9 not invoked.
✗ Call 12 not invoked.
✗ Call 15 not invoked.
✗ Call 18 not invoked.
✗ Call 21 not invoked.
✗ Call 24 not invoked.
✗ Call 27 not invoked.
✗ Call 30 not invoked.
✗ Call 33 not invoked.
✗ Call 34 not invoked.
✗ Call 35 not invoked.
✗ Call 36 not invoked.
✗ Call 39 not invoked.
|
✗ |
}; |
| 48 |
|
|
|
✗ |
static const auto colorFor = [](const int n) -> QColor { |
| 49 |
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
0/2
✗ Call 4 not invoked.
✗ Call 5 not invoked.
|
✗ |
if (n >= 30 && n <= 37) return palette[n - 30]; |
| 50 |
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
0/2
✗ Call 4 not invoked.
✗ Call 5 not invoked.
|
✗ |
if (n >= 90 && n <= 97) return palette[n - 90]; |
| 51 |
|
|
0/1
✗ Call 0 not invoked.
|
✗ |
return {}; |
| 52 |
|
|
|
|
}; |
| 53 |
|
|
|
|
|
| 54 |
|
|
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
|
✗ |
QList<QColor> colors; |
| 55 |
|
|
0/6
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
|
✗ |
auto it = ansiRegex.globalMatch(text); |
| 56 |
|
0/1
? Decision couldn't be analyzed.
|
0/1
✗ Call 0 not invoked.
|
✗ |
while (it.hasNext()) { |
| 57 |
|
0/1
? Decision couldn't be analyzed.
|
0/28
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
✗ Call 19 not invoked.
✗ Call 20 not invoked.
✗ Call 21 not invoked.
✗ Call 22 not invoked.
✗ Call 25 not invoked.
✗ Call 26 not invoked.
✗ Call 27 not invoked.
✗ Call 30 not invoked.
✗ Call 33 not invoked.
✗ Call 34 not invoked.
✗ Call 35 not invoked.
✗ Call 38 not invoked.
✗ Call 39 not invoked.
✗ Call 40 not invoked.
✗ Call 41 not invoked.
|
✗ |
for (const auto match = it.next(); const QString& code: match.captured(1).split(';')) { |
| 58 |
|
|
0/2
✗ Call 0 not invoked.
✗ Call 1 not invoked.
|
✗ |
const int n = code.toInt(); |
| 59 |
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 4 not invoked.
✗ Call 7 not invoked.
|
✗ |
if (const QColor c = colorFor(n); c.isValid()) colors.append(c); |
| 60 |
|
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
|
✗ |
} |
| 61 |
|
|
|
|
} |
| 62 |
|
|
|
|
|
| 63 |
|
|
0/11
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
|
✗ |
const QString clean = QString(text).remove(ansiRegex); |
| 64 |
|
|
|
|
|
| 65 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
|
✗ |
const int levelStart = clean.indexOf('['); |
| 66 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
|
✗ |
const int levelEnd = clean.indexOf(']', levelStart + 1); |
| 67 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
|
✗ |
const int nameStart = clean.indexOf('[', levelEnd + 1); |
| 68 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
|
✗ |
const int nameEnd = clean.indexOf(']', nameStart + 1); |
| 69 |
|
|
|
|
|
| 70 |
|
|
0/14
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
|
✗ |
cursor_.insertText(clean.mid(0, levelStart), defaultFormat_); |
| 71 |
|
|
|
|
|
| 72 |
|
|
0/13
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
|
✗ |
coloredFormat_.setForeground(colors[0]); |
| 73 |
|
|
0/14
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
|
✗ |
cursor_.insertText(clean.mid(levelStart, levelEnd - levelStart + 1), coloredFormat_); |
| 74 |
|
|
|
|
|
| 75 |
|
|
0/14
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
|
✗ |
cursor_.insertText(clean.mid(levelEnd + 1, nameStart - levelEnd - 1), defaultFormat_); |
| 76 |
|
|
|
|
|
| 77 |
|
|
0/13
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
|
✗ |
coloredFormat_.setForeground(colors[1]); |
| 78 |
|
|
0/14
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
|
✗ |
cursor_.insertText(clean.mid(nameStart, nameEnd - nameStart + 1), coloredFormat_); |
| 79 |
|
|
|
|
|
| 80 |
|
|
0/14
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
|
✗ |
cursor_.insertText(clean.mid(nameEnd + 1), defaultFormat_); |
| 81 |
|
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
|
✗ |
cursor_.insertBlock(); |
| 82 |
|
|
0/6
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
|
✗ |
} |
| 83 |
|
|
|
|
|
| 84 |
|
|
|
✗ |
void LoggerTextEditSink::showEvent(QShowEvent* show_event) { |
| 85 |
|
|
0/20
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
✗ Call 19 not invoked.
|
✗ |
verticalScrollBar()->setValue(verticalScrollBar()->maximum()); |
| 86 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
|
✗ |
QTextEdit::showEvent(show_event); |
| 87 |
|
|
|
✗ |
} |
| 88 |
|
|
|
|
|