mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
Merge pull request #12243 from RebeccaStankus/log-filtering
Some improvements to the log window
This commit is contained in:
commit
64c5b883b1
5 changed files with 75 additions and 24 deletions
|
@ -67,7 +67,7 @@ QPushButton#revealLogButton {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton#showAllButton {
|
QPushButton#allLogsButton {
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
background-color: #333333;
|
background-color: #333333;
|
||||||
color: #BBBBBB;
|
color: #BBBBBB;
|
||||||
|
@ -112,4 +112,11 @@ QComboBox::drop-down {
|
||||||
QComboBox::down-arrow {
|
QComboBox::down-arrow {
|
||||||
image: url(:/styles/filter.png);
|
image: url(:/styles/filter.png);
|
||||||
border-width: 0px;
|
border-width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLabel#messageCount {
|
||||||
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
color: #3d3d3d;
|
||||||
|
font-size: 11px;
|
||||||
}
|
}
|
|
@ -29,8 +29,8 @@ const int SEARCH_TOGGLE_BUTTON_WIDTH = 50;
|
||||||
const int SEARCH_TEXT_WIDTH = 240;
|
const int SEARCH_TEXT_WIDTH = 240;
|
||||||
const int TIME_STAMP_LENGTH = 16;
|
const int TIME_STAMP_LENGTH = 16;
|
||||||
const int FONT_WEIGHT = 75;
|
const int FONT_WEIGHT = 75;
|
||||||
const QColor HIGHLIGHT_COLOR = QColor("#3366CC");
|
const QColor HIGHLIGHT_COLOR = QColor("#00B4EF");
|
||||||
const QColor BOLD_COLOR = QColor("#445c8c");
|
const QColor BOLD_COLOR = QColor("#1080B8");
|
||||||
const QString BOLD_PATTERN = "\\[\\d*\\/.*:\\d*:\\d*\\]";
|
const QString BOLD_PATTERN = "\\[\\d*\\/.*:\\d*:\\d*\\]";
|
||||||
|
|
||||||
BaseLogDialog::BaseLogDialog(QWidget* parent) : QDialog(parent, Qt::Window) {
|
BaseLogDialog::BaseLogDialog(QWidget* parent) : QDialog(parent, Qt::Window) {
|
||||||
|
@ -182,6 +182,7 @@ void BaseLogDialog::updateSelection() {
|
||||||
Highlighter::Highlighter(QTextDocument* parent) : QSyntaxHighlighter(parent) {
|
Highlighter::Highlighter(QTextDocument* parent) : QSyntaxHighlighter(parent) {
|
||||||
boldFormat.setFontWeight(FONT_WEIGHT);
|
boldFormat.setFontWeight(FONT_WEIGHT);
|
||||||
boldFormat.setForeground(BOLD_COLOR);
|
boldFormat.setForeground(BOLD_COLOR);
|
||||||
|
keywordFormat.setFontWeight(FONT_WEIGHT);
|
||||||
keywordFormat.setForeground(HIGHLIGHT_COLOR);
|
keywordFormat.setForeground(HIGHLIGHT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
#include <shared/AbstractLoggerInterface.h>
|
#include <shared/AbstractLoggerInterface.h>
|
||||||
|
|
||||||
const int REVEAL_BUTTON_WIDTH = 122;
|
const int REVEAL_BUTTON_WIDTH = 122;
|
||||||
const int CLEAR_FILTER_BUTTON_WIDTH = 80;
|
const int ALL_LOGS_BUTTON_WIDTH = 90;
|
||||||
const int MARGIN_LEFT = 25;
|
const int MARGIN_LEFT = 25;
|
||||||
const int DEBUG_CHECKBOX_WIDTH = 70;
|
const int DEBUG_CHECKBOX_WIDTH = 70;
|
||||||
const int INFO_CHECKBOX_WIDTH = 65;
|
const int INFO_CHECKBOX_WIDTH = 65;
|
||||||
|
@ -142,6 +143,11 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLog
|
||||||
_filterDropdown->addItem("qml");
|
_filterDropdown->addItem("qml");
|
||||||
connect(_filterDropdown, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &LogDialog::handleFilterDropdownChanged);
|
connect(_filterDropdown, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &LogDialog::handleFilterDropdownChanged);
|
||||||
|
|
||||||
|
_leftPad += COMBOBOX_WIDTH + MARGIN_LEFT + MARGIN_LEFT;
|
||||||
|
_messageCount = new QLabel("", this);
|
||||||
|
_messageCount->setObjectName("messageCount");
|
||||||
|
_messageCount->show();
|
||||||
|
|
||||||
_extraDebuggingBox = new QCheckBox("Extra debugging", this);
|
_extraDebuggingBox = new QCheckBox("Extra debugging", this);
|
||||||
if (_logger->extraDebugging()) {
|
if (_logger->extraDebugging()) {
|
||||||
_extraDebuggingBox->setCheckState(Qt::Checked);
|
_extraDebuggingBox->setCheckState(Qt::Checked);
|
||||||
|
@ -149,12 +155,13 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLog
|
||||||
_extraDebuggingBox->show();
|
_extraDebuggingBox->show();
|
||||||
connect(_extraDebuggingBox, &QCheckBox::stateChanged, this, &LogDialog::handleExtraDebuggingCheckbox);
|
connect(_extraDebuggingBox, &QCheckBox::stateChanged, this, &LogDialog::handleExtraDebuggingCheckbox);
|
||||||
|
|
||||||
_clearFilterButton = new QPushButton("Clear Filters", this);
|
_allLogsButton = new QPushButton("All Messages", this);
|
||||||
// set object name for css styling
|
// set object name for css styling
|
||||||
_clearFilterButton->setObjectName("showAllButton");
|
|
||||||
_clearFilterButton->show();
|
_allLogsButton->setObjectName("allLogsButton");
|
||||||
connect(_clearFilterButton, &QPushButton::clicked, this, &LogDialog::handleClearFilterButton);
|
_allLogsButton->show();
|
||||||
handleClearFilterButton();
|
connect(_allLogsButton, &QPushButton::clicked, this, &LogDialog::handleAllLogsButton);
|
||||||
|
handleAllLogsButton();
|
||||||
|
|
||||||
auto windowGeometry = _windowGeometry.get();
|
auto windowGeometry = _windowGeometry.get();
|
||||||
if (windowGeometry.isValid()) {
|
if (windowGeometry.isValid()) {
|
||||||
|
@ -168,11 +175,15 @@ void LogDialog::resizeEvent(QResizeEvent* event) {
|
||||||
ELEMENT_MARGIN,
|
ELEMENT_MARGIN,
|
||||||
REVEAL_BUTTON_WIDTH,
|
REVEAL_BUTTON_WIDTH,
|
||||||
ELEMENT_HEIGHT);
|
ELEMENT_HEIGHT);
|
||||||
_clearFilterButton->setGeometry(width() - ELEMENT_MARGIN - CLEAR_FILTER_BUTTON_WIDTH,
|
_allLogsButton->setGeometry(width() - ELEMENT_MARGIN - ALL_LOGS_BUTTON_WIDTH,
|
||||||
THIRD_ROW,
|
THIRD_ROW,
|
||||||
CLEAR_FILTER_BUTTON_WIDTH,
|
ALL_LOGS_BUTTON_WIDTH,
|
||||||
ELEMENT_HEIGHT);
|
ELEMENT_HEIGHT);
|
||||||
_extraDebuggingBox->setGeometry(width() - ELEMENT_MARGIN - COMBOBOX_WIDTH - ELEMENT_MARGIN - CLEAR_FILTER_BUTTON_WIDTH,
|
_extraDebuggingBox->setGeometry(width() - ELEMENT_MARGIN - COMBOBOX_WIDTH - ELEMENT_MARGIN - ALL_LOGS_BUTTON_WIDTH,
|
||||||
|
THIRD_ROW,
|
||||||
|
COMBOBOX_WIDTH,
|
||||||
|
ELEMENT_HEIGHT);
|
||||||
|
_messageCount->setGeometry(_leftPad,
|
||||||
THIRD_ROW,
|
THIRD_ROW,
|
||||||
COMBOBOX_WIDTH,
|
COMBOBOX_WIDTH,
|
||||||
ELEMENT_HEIGHT);
|
ELEMENT_HEIGHT);
|
||||||
|
@ -187,13 +198,13 @@ void LogDialog::handleRevealButton() {
|
||||||
_logger->locateLog();
|
_logger->locateLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogDialog::handleClearFilterButton() {
|
void LogDialog::handleAllLogsButton() {
|
||||||
_logger->setExtraDebugging(false);
|
_logger->setExtraDebugging(false);
|
||||||
_extraDebuggingBox->setCheckState(Qt::Unchecked);
|
_extraDebuggingBox->setCheckState(Qt::Unchecked);
|
||||||
_logger->setDebugPrint(false);
|
_logger->setDebugPrint(true);
|
||||||
_debugPrintBox->setCheckState(Qt::Unchecked);
|
_debugPrintBox->setCheckState(Qt::Checked);
|
||||||
_logger->setInfoPrint(false);
|
_logger->setInfoPrint(true);
|
||||||
_infoPrintBox->setCheckState(Qt::Unchecked);
|
_infoPrintBox->setCheckState(Qt::Checked);
|
||||||
_logger->setCriticalPrint(true);
|
_logger->setCriticalPrint(true);
|
||||||
_criticalPrintBox->setCheckState(Qt::Checked);
|
_criticalPrintBox->setCheckState(Qt::Checked);
|
||||||
_logger->setWarningPrint(true);
|
_logger->setWarningPrint(true);
|
||||||
|
@ -270,40 +281,67 @@ void LogDialog::appendLogLine(QString logLine) {
|
||||||
if (logLine.contains(DEBUG_TEXT, Qt::CaseSensitive)) {
|
if (logLine.contains(DEBUG_TEXT, Qt::CaseSensitive)) {
|
||||||
if (_logger->debugPrint()) {
|
if (_logger->debugPrint()) {
|
||||||
_logTextBox->appendPlainText(logLine.trimmed());
|
_logTextBox->appendPlainText(logLine.trimmed());
|
||||||
|
_count++;
|
||||||
|
updateMessageCount();
|
||||||
}
|
}
|
||||||
} else if (logLine.contains(INFO_TEXT, Qt::CaseSensitive)) {
|
} else if (logLine.contains(INFO_TEXT, Qt::CaseSensitive)) {
|
||||||
if (_logger->infoPrint()) {
|
if (_logger->infoPrint()) {
|
||||||
_logTextBox->appendPlainText(logLine.trimmed());
|
_logTextBox->appendPlainText(logLine.trimmed());
|
||||||
|
_count++;
|
||||||
|
updateMessageCount();
|
||||||
}
|
}
|
||||||
} else if (logLine.contains(CRITICAL_TEXT, Qt::CaseSensitive)) {
|
} else if (logLine.contains(CRITICAL_TEXT, Qt::CaseSensitive)) {
|
||||||
if (_logger->criticalPrint()) {
|
if (_logger->criticalPrint()) {
|
||||||
_logTextBox->appendPlainText(logLine.trimmed());
|
_logTextBox->appendPlainText(logLine.trimmed());
|
||||||
|
_count++;
|
||||||
|
updateMessageCount();
|
||||||
}
|
}
|
||||||
} else if (logLine.contains(WARNING_TEXT, Qt::CaseSensitive)) {
|
} else if (logLine.contains(WARNING_TEXT, Qt::CaseSensitive)) {
|
||||||
if (_logger->warningPrint()) {
|
if (_logger->warningPrint()) {
|
||||||
_logTextBox->appendPlainText(logLine.trimmed());
|
_logTextBox->appendPlainText(logLine.trimmed());
|
||||||
|
_count++;
|
||||||
|
updateMessageCount();
|
||||||
}
|
}
|
||||||
} else if (logLine.contains(SUPPRESS_TEXT, Qt::CaseSensitive)) {
|
} else if (logLine.contains(SUPPRESS_TEXT, Qt::CaseSensitive)) {
|
||||||
if (_logger->suppressPrint()) {
|
if (_logger->suppressPrint()) {
|
||||||
_logTextBox->appendPlainText(logLine.trimmed());
|
_logTextBox->appendPlainText(logLine.trimmed());
|
||||||
|
_count++;
|
||||||
|
updateMessageCount();
|
||||||
}
|
}
|
||||||
} else if (logLine.contains(FATAL_TEXT, Qt::CaseSensitive)) {
|
} else if (logLine.contains(FATAL_TEXT, Qt::CaseSensitive)) {
|
||||||
if (_logger->fatalPrint()) {
|
if (_logger->fatalPrint()) {
|
||||||
_logTextBox->appendPlainText(logLine.trimmed());
|
_logTextBox->appendPlainText(logLine.trimmed());
|
||||||
|
_count++;
|
||||||
|
updateMessageCount();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_logger->unknownPrint()) {
|
if (_logger->unknownPrint() && logLine.trimmed() != "") {
|
||||||
_logTextBox->appendPlainText(logLine.trimmed());
|
_logTextBox->appendPlainText(logLine.trimmed());
|
||||||
|
_count++;
|
||||||
|
updateMessageCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogDialog::printLogFile() {
|
void LogDialog::printLogFile() {
|
||||||
|
_count = 0;
|
||||||
_logTextBox->clear();
|
_logTextBox->clear();
|
||||||
QString log = getCurrentLog();
|
QString log = getCurrentLog();
|
||||||
QStringList logList = log.split('\n');
|
QStringList logList = log.split('\n');
|
||||||
for (const auto& message : logList) {
|
for (const auto& message : logList) {
|
||||||
appendLogLine(message);
|
appendLogLine(message);
|
||||||
}
|
}
|
||||||
|
updateMessageCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogDialog::updateMessageCount() {
|
||||||
|
_countLabel = QString::number(_count);
|
||||||
|
if (_count != 1) {
|
||||||
|
_countLabel.append(" log messages");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_countLabel.append(" log message");
|
||||||
|
}
|
||||||
|
_messageCount->setText(_countLabel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
class QLabel;
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
class AbstractLoggerInterface;
|
class AbstractLoggerInterface;
|
||||||
|
|
||||||
|
@ -41,19 +42,21 @@ private slots:
|
||||||
void handleFatalPrintBox(int);
|
void handleFatalPrintBox(int);
|
||||||
void handleUnknownPrintBox(int);
|
void handleUnknownPrintBox(int);
|
||||||
void handleFilterDropdownChanged(int);
|
void handleFilterDropdownChanged(int);
|
||||||
void handleClearFilterButton();
|
void handleAllLogsButton();
|
||||||
|
void printLogFile();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
QString getCurrentLog() override;
|
QString getCurrentLog() override;
|
||||||
void printLogFile();
|
void updateMessageCount();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCheckBox* _extraDebuggingBox;
|
QCheckBox* _extraDebuggingBox;
|
||||||
QPushButton* _revealLogButton;
|
QPushButton* _revealLogButton;
|
||||||
QPushButton* _clearFilterButton;
|
QPushButton* _allLogsButton;
|
||||||
QCheckBox* _debugPrintBox;
|
QCheckBox* _debugPrintBox;
|
||||||
QCheckBox* _infoPrintBox;
|
QCheckBox* _infoPrintBox;
|
||||||
QCheckBox* _criticalPrintBox;
|
QCheckBox* _criticalPrintBox;
|
||||||
|
@ -62,10 +65,12 @@ private:
|
||||||
QCheckBox* _fatalPrintBox;
|
QCheckBox* _fatalPrintBox;
|
||||||
QCheckBox* _unknownPrintBox;
|
QCheckBox* _unknownPrintBox;
|
||||||
QComboBox* _filterDropdown;
|
QComboBox* _filterDropdown;
|
||||||
|
QLabel* _messageCount;
|
||||||
QString _filterSelection;
|
QString _filterSelection;
|
||||||
|
QString _countLabel;
|
||||||
AbstractLoggerInterface* _logger;
|
AbstractLoggerInterface* _logger;
|
||||||
Setting::Handle<QRect> _windowGeometry;
|
Setting::Handle<QRect> _windowGeometry;
|
||||||
|
int _count = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_LogDialog_h
|
#endif // hifi_LogDialog_h
|
||||||
|
|
|
@ -50,8 +50,8 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _extraDebugging{ false };
|
bool _extraDebugging{ false };
|
||||||
bool _debugPrint{ false };
|
bool _debugPrint{ true };
|
||||||
bool _infoPrint{ false };
|
bool _infoPrint{ true };
|
||||||
bool _criticalPrint{ true };
|
bool _criticalPrint{ true };
|
||||||
bool _warningPrint{ true };
|
bool _warningPrint{ true };
|
||||||
bool _suppressPrint{ true };
|
bool _suppressPrint{ true };
|
||||||
|
|
Loading…
Reference in a new issue