GH-1053 move guessLevel to instances
This commit is contained in:
parent
2fc18921b0
commit
6310f6569c
@ -25,6 +25,7 @@
|
|||||||
#include "settings/INIFile.h"
|
#include "settings/INIFile.h"
|
||||||
#include "BaseVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
#include "auth/MojangAccount.h"
|
#include "auth/MojangAccount.h"
|
||||||
|
#include "launch/MessageLevel.h"
|
||||||
|
|
||||||
class QDir;
|
class QDir;
|
||||||
class Task;
|
class Task;
|
||||||
@ -94,6 +95,12 @@ public:
|
|||||||
QString getPostExitCommand();
|
QString getPostExitCommand();
|
||||||
QString getWrapperCommand();
|
QString getWrapperCommand();
|
||||||
|
|
||||||
|
/// guess log level from a line of game log
|
||||||
|
virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level)
|
||||||
|
{
|
||||||
|
return level;
|
||||||
|
};
|
||||||
|
|
||||||
virtual QStringList extraArguments() const;
|
virtual QStringList extraArguments() const;
|
||||||
|
|
||||||
virtual QString intendedVersionId() const = 0;
|
virtual QString intendedVersionId() const = 0;
|
||||||
|
@ -119,47 +119,6 @@ QString LaunchTask::censorPrivateInfo(QString in)
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
// console window
|
|
||||||
MessageLevel::Enum LaunchTask::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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LaunchTask::proceed()
|
void LaunchTask::proceed()
|
||||||
{
|
{
|
||||||
if(state != LaunchTask::Waiting)
|
if(state != LaunchTask::Waiting)
|
||||||
@ -223,7 +182,7 @@ void LaunchTask::onLogLine(QString line, MessageLevel::Enum level)
|
|||||||
// If the level is still undetermined, guess level
|
// If the level is still undetermined, guess level
|
||||||
if (level == MessageLevel::StdErr || level == MessageLevel::StdOut || level == MessageLevel::Unknown)
|
if (level == MessageLevel::StdErr || level == MessageLevel::StdOut || level == MessageLevel::Unknown)
|
||||||
{
|
{
|
||||||
level = this->guessLevel(line, level);
|
level = m_instance->guessLevel(line, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// censor private user info
|
// censor private user info
|
||||||
|
@ -21,18 +21,7 @@
|
|||||||
#include "MessageLevel.h"
|
#include "MessageLevel.h"
|
||||||
#include "LoggedProcess.h"
|
#include "LoggedProcess.h"
|
||||||
#include "LaunchStep.h"
|
#include "LaunchStep.h"
|
||||||
/* HACK: MINECRAFT: split! */
|
|
||||||
#include "minecraft/MinecraftInstance.h"
|
|
||||||
#include "java/JavaChecker.h"
|
|
||||||
#include "QObjectPtr.h"
|
|
||||||
#include "tasks/Task.h"
|
|
||||||
|
|
||||||
class ProcessTask
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class BaseProfilerFactory;
|
|
||||||
class LaunchTask: public Task
|
class LaunchTask: public Task
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -89,13 +78,9 @@ public: /* methods */
|
|||||||
*/
|
*/
|
||||||
virtual bool abort() override;
|
virtual bool abort() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
public: /* HACK: remove this from here! */
|
|
||||||
|
|
||||||
QString substituteVariables(const QString &cmd) const;
|
QString substituteVariables(const QString &cmd) const;
|
||||||
QString censorPrivateInfo(QString in);
|
QString censorPrivateInfo(QString in);
|
||||||
virtual MessageLevel::Enum guessLevel(const QString &message, MessageLevel::Enum defaultLevel);
|
|
||||||
|
|
||||||
protected: /* methods */
|
protected: /* methods */
|
||||||
virtual void emitFailed(QString reason);
|
virtual void emitFailed(QString reason);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "CheckJava.h"
|
#include "CheckJava.h"
|
||||||
#include <launch/LaunchTask.h>
|
#include <launch/LaunchTask.h>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
void CheckJava::executeTask()
|
void CheckJava::executeTask()
|
||||||
{
|
{
|
||||||
|
@ -204,4 +204,44 @@ QProcessEnvironment MinecraftInstance::createEnvironment()
|
|||||||
return env;
|
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"
|
#include "MinecraftInstance.moc"
|
||||||
|
@ -40,6 +40,9 @@ public:
|
|||||||
|
|
||||||
/// create an environment for launching processes
|
/// create an environment for launching processes
|
||||||
virtual QProcessEnvironment createEnvironment() override;
|
virtual QProcessEnvironment createEnvironment() override;
|
||||||
|
|
||||||
|
/// guess log level from a line of minecraft log
|
||||||
|
virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<MinecraftInstance> MinecraftInstancePtr;
|
typedef std::shared_ptr<MinecraftInstance> MinecraftInstancePtr;
|
||||||
|
Loading…
Reference in New Issue
Block a user