mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 13:17:41 +02:00
feat(xml-logs): finish tests
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@ -1004,49 +1004,6 @@ QMap<QString, QString> MinecraftInstance::createCensorFilterFromSession(AuthSess
|
||||
return filter;
|
||||
}
|
||||
|
||||
MessageLevel::Enum MinecraftInstance::guessLevel(const QString& line, MessageLevel::Enum level)
|
||||
{
|
||||
if (line.contains("overwriting existing"))
|
||||
return MessageLevel::Fatal;
|
||||
|
||||
// NOTE: this diverges from the real regexp. no unicode, the first section is + instead of *
|
||||
static const QRegularExpression JAVA_EXCEPTION(
|
||||
R"(Exception in thread|...\d more$|(\s+at |Caused by: )([a-zA-Z_$][a-zA-Z\d_$]*\.)+[a-zA-Z_$][a-zA-Z\d_$]*)|([a-zA-Z_$][a-zA-Z\d_$]*\.)+[a-zA-Z_$][a-zA-Z\d_$]*(Exception|Error|Throwable)");
|
||||
|
||||
if (line.contains(JAVA_EXCEPTION))
|
||||
return MessageLevel::Error;
|
||||
|
||||
static const QRegularExpression LINE_WITH_LEVEL("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
|
||||
auto match = LINE_WITH_LEVEL.match(line);
|
||||
if (match.hasMatch()) {
|
||||
// New style logs from log4j
|
||||
QString timestamp = match.captured("timestamp");
|
||||
QString levelStr = match.captured("level");
|
||||
if (levelStr == "INFO")
|
||||
level = MessageLevel::Message;
|
||||
if (levelStr == "WARN")
|
||||
level = MessageLevel::Warning;
|
||||
if (levelStr == "ERROR")
|
||||
level = MessageLevel::Error;
|
||||
if (levelStr == "FATAL")
|
||||
level = MessageLevel::Fatal;
|
||||
if (levelStr == "TRACE" || levelStr == "DEBUG")
|
||||
level = MessageLevel::Debug;
|
||||
} else {
|
||||
// Old style forge logs
|
||||
if (line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]") || line.contains("[FINER]") ||
|
||||
line.contains("[FINEST]"))
|
||||
level = MessageLevel::Message;
|
||||
if (line.contains("[SEVERE]") || line.contains("[STDERR]"))
|
||||
level = MessageLevel::Error;
|
||||
if (line.contains("[WARNING]"))
|
||||
level = MessageLevel::Warning;
|
||||
if (line.contains("[DEBUG]"))
|
||||
level = MessageLevel::Debug;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
IPathMatcher::Ptr MinecraftInstance::getLogFileMatcher()
|
||||
{
|
||||
auto combined = std::make_shared<MultiMatcher>();
|
||||
|
@ -139,9 +139,6 @@ class MinecraftInstance : public BaseInstance {
|
||||
QProcessEnvironment createEnvironment() override;
|
||||
QProcessEnvironment createLaunchEnvironment() override;
|
||||
|
||||
/// guess log level from a line of minecraft log
|
||||
MessageLevel::Enum guessLevel(const QString& line, MessageLevel::Enum level) override;
|
||||
|
||||
IPathMatcher::Ptr getLogFileMatcher() override;
|
||||
|
||||
QString getLogFileRoot() override;
|
||||
|
Reference in New Issue
Block a user