summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-11-09 14:53:08 +0100
committerPetr Mrázek <peterix@gmail.com>2014-11-09 14:53:08 +0100
commit2e9284951c7364dc766a406099ce3a779773abb1 (patch)
tree67c5ac688edc42027e7815bd1d5614c3d1458a9f /logic
parentf9a7c1cf216a464c922ca47a60a6f44ebd7decc9 (diff)
downloadMultiMC-2e9284951c7364dc766a406099ce3a779773abb1.tar
MultiMC-2e9284951c7364dc766a406099ce3a779773abb1.tar.gz
MultiMC-2e9284951c7364dc766a406099ce3a779773abb1.tar.lz
MultiMC-2e9284951c7364dc766a406099ce3a779773abb1.tar.xz
MultiMC-2e9284951c7364dc766a406099ce3a779773abb1.zip
Improve log formatting
* Updated log level detection for current Minecraft versions * Better formatting: using a monospaced font and raw text instead of HTML (fixes #111)
Diffstat (limited to 'logic')
-rw-r--r--logic/MinecraftProcess.cpp46
1 files changed, 34 insertions, 12 deletions
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp
index 5c74fefe..c9738176 100644
--- a/logic/MinecraftProcess.cpp
+++ b/logic/MinecraftProcess.cpp
@@ -144,19 +144,41 @@ QString MinecraftProcess::censorPrivateInfo(QString in)
// console window
MessageLevel::Enum MinecraftProcess::guessLevel(const QString &line, MessageLevel::Enum level)
{
- 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("Exception in thread") || line.contains(" at "))
- level = MessageLevel::Fatal;
- if (line.contains("[DEBUG]"))
- level = MessageLevel::Debug;
+ 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"))
- level = MessageLevel::Fatal;
+ return MessageLevel::Fatal;
+ if (line.contains("Exception in thread") || line.contains(" at "))
+ return MessageLevel::Fatal;
return level;
}