Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if(WIN32)
set(CMAKE_WIN32_EXECUTABLE ON)
endif()

find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt6 COMPONENTS Widgets REQUIRED)


file(GLOB SRC_FILES "src/*.cpp" "src/*.ui")
Expand All @@ -24,15 +24,15 @@ target_sources(QLogViewer PRIVATE ${SRC_FILES})
include_directories(src)


target_link_libraries(QLogViewer Qt5::Widgets)
target_link_libraries(QLogViewer Qt6::Widgets)


include(FetchContent)

FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG 0579ae3d976091d7d664aa9d2527e0d0cff25763
GIT_TAG master
)

set(YAML_CPP_BUILD_TESTS OFF)
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevelAreaWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LogLevelAreaWidget : public EditInfoAreaWidget
int maxChars = 0;
for(const auto& level : usedLevels)
{
maxChars = std::max(maxChars, level->GetLevelName().length());
maxChars = std::max(maxChars, (int)level->GetLevelName().length());
}
SetWidthForCharCount(maxChars);
}
Expand Down
38 changes: 29 additions & 9 deletions src/LogParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
#include <QRegularExpression>
#include <memory>

namespace
{
const QString MATCH_GROUP_DATE = "date";
const QString MATCH_GROUP_TIME = "time";
const QString MATCH_GROUP_THREAD = "thread";
const QString MATCH_GROUP_SUBSYS = "subsys";
const QString MATCH_GROUP_MESSAGE = "message";
const QString MATCH_GROUP_WHERE = "where";
const QString MATCH_GROUP_LEVEL = "level";
}

LogParser::~LogParser()
{
if (ownsFile)
Expand Down Expand Up @@ -62,7 +73,7 @@ std::vector<LogEntry> LogParser::Parse()
{
inputStream = std::make_unique<QTextStream>(&logMessage, QIODevice::ReadOnly);
}
inputStream->setCodec("UTF-8");
inputStream->setEncoding(QStringConverter::Utf8);

FindLogProfile(inputStream.get());

Expand Down Expand Up @@ -119,24 +130,34 @@ QString LogParser::GetNextMessage(QTextStream& inputStream)
return message;
}

QString GetMatchFromRawData(const QRegularExpressionMatch& match, const QString& group)
{
QStringView view = match.capturedView(group);
return QString::fromRawData((QChar*)view.utf16(), view.length());
}

LogEntry LogParser::ParseMessage(const QString& message, uint64_t startLineNumber)
{
LogEntry e;
e.entryNumber = ++entryCount;
e.lineNumber = startLineNumber;
const auto match = logEntryRegex.match(message);
TryExtractEnvironment(message);

e.components[LogComponent::ORIGINAL_MESSAGE] = message;

if (match.hasMatch())
{
e.components[LogComponent::DATE] = match.captured("date");
e.components[LogComponent::TIME] = match.captured("time");
e.components[LogComponent::THREAD] = match.captured("thread");
e.components[LogComponent::SUB_SYS] = match.captured("subsys");
e.components[LogComponent::MESSAGE] = match.captured("message");
e.components[LogComponent::WHERE] = match.captured("where");
e.components[LogComponent::DATE] = GetMatchFromRawData(match, MATCH_GROUP_DATE);
e.components[LogComponent::TIME] = GetMatchFromRawData(match, MATCH_GROUP_TIME);
e.components[LogComponent::THREAD] = GetMatchFromRawData(match, MATCH_GROUP_THREAD);
e.components[LogComponent::SUB_SYS] = GetMatchFromRawData(match, MATCH_GROUP_SUBSYS);
e.components[LogComponent::MESSAGE] = GetMatchFromRawData(match, MATCH_GROUP_MESSAGE);
e.components[LogComponent::WHERE] = GetMatchFromRawData(match, MATCH_GROUP_WHERE);

// Read log level
e.level = GetLogLevel(match.captured("level"));
const QString type = GetMatchFromRawData(match, MATCH_GROUP_LEVEL);
e.level = GetLogLevel(type);

//TODO
e.timeStamp = QDateTime::fromString("20" + e.components[LogComponent::DATE] + ' ' + e.components[LogComponent::TIME], Qt::ISODateWithMs);
Expand All @@ -146,7 +167,6 @@ LogEntry LogParser::ParseMessage(const QString& message, uint64_t startLineNumbe
e.components[LogComponent::MESSAGE] = message;
e.level = GetLogLevel("");
}
e.components[LogComponent::ORIGINAL_MESSAGE] = message;

return e;
}
Expand Down
2 changes: 1 addition & 1 deletion src/LogProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ QString LogProfile::FilterName(QString name)
name = name.left(40);
}
// Remove special chars
name.remove(QRegExp("[¥/\\.?*|<>:]"));
name.remove(QRegularExpression("[¥/\\.?*|<>:]"));
return name;
}

Expand Down
4 changes: 4 additions & 0 deletions src/LogViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ LogViewer::LogViewer(QWidget *parent) : InfoAreaEnabledPlainTextEdit(parent)
QFont font("Monospace");
font.setStyleHint(QFont::TypeWriter);
setFont(font);

setUndoRedoEnabled(false);
setUpdatesEnabled(false);
}

void LogViewer::SetLogHolder(LogHolder* holder)
Expand Down Expand Up @@ -72,6 +75,7 @@ void LogViewer::UpdateLogView()
}
{
BlockProfiler setProfiler("Set log view");
// Based on application_621.log: The method call below causes a memory consumption of 54MB
setPlainText(string);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/LogViewerTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void LogViewerTab::Load(QFile* file)
file->close();
{
BlockProfiler profilerSetFullLog("Set full log view");
// Based on application_621.log: Below method call causes 94MB of memory usage
ui.fullLogView->setPlainText(log);
}

Expand Down
2 changes: 1 addition & 1 deletion src/SettingsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void SettingsWindow::on_logLevelTable_cellClicked(int row, int column)
if (color.isValid())
{
ui.logLevelTable->setItem(row, column, new QTableWidgetItem(color.name()));
ui.logLevelTable->item(row, column)->setBackgroundColor(color);
ui.logLevelTable->item(row, column)->setBackground(color);
}
}

Expand Down
Loading