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)
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user