summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/MinecraftInstance.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-07-22 09:01:04 +0200
committerPetr Mrázek <peterix@gmail.com>2015-07-22 09:01:04 +0200
commit6310f6569c2630f27ad72dc0a5fef9f9fec5a88c (patch)
tree472be93fc6d94d38e0830d87186eee25c01dcb9c /logic/minecraft/MinecraftInstance.cpp
parent2fc18921b04536285ad82e49d61faaeb599c6d46 (diff)
downloadMultiMC-6310f6569c2630f27ad72dc0a5fef9f9fec5a88c.tar
MultiMC-6310f6569c2630f27ad72dc0a5fef9f9fec5a88c.tar.gz
MultiMC-6310f6569c2630f27ad72dc0a5fef9f9fec5a88c.tar.lz
MultiMC-6310f6569c2630f27ad72dc0a5fef9f9fec5a88c.tar.xz
MultiMC-6310f6569c2630f27ad72dc0a5fef9f9fec5a88c.zip
GH-1053 move guessLevel to instances
Diffstat (limited to 'logic/minecraft/MinecraftInstance.cpp')
-rw-r--r--logic/minecraft/MinecraftInstance.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/logic/minecraft/MinecraftInstance.cpp b/logic/minecraft/MinecraftInstance.cpp
index a078c8fd..13e696b9 100644
--- a/logic/minecraft/MinecraftInstance.cpp
+++ b/logic/minecraft/MinecraftInstance.cpp
@@ -204,4 +204,44 @@ QProcessEnvironment MinecraftInstance::createEnvironment()
return env;
}
+MessageLevel::Enum MinecraftInstance::guessLevel(const QString &line, MessageLevel::Enum level)
+{
+ QRegularExpression re("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
+ auto match = re.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;
+ }
+ if (line.contains("overwriting existing"))
+ return MessageLevel::Fatal;
+ if (line.contains("Exception in thread") || line.contains(QRegularExpression("\\s+at ")))
+ return MessageLevel::Error;
+ return level;
+}
+
#include "MinecraftInstance.moc"