mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-26 18:14:22 +00:00
Filter console output, no more sea of red when there's nothing to report.
This commit is contained in:
parent
d2eef6974b
commit
d24c4823ef
@ -104,6 +104,8 @@ protected:
|
||||
InstancePtr m_instance;
|
||||
QString m_user;
|
||||
QString m_session;
|
||||
QString m_err_leftover;
|
||||
QString m_out_leftover;
|
||||
QProcess m_prepostlaunchprocess;
|
||||
QStringList m_arguments;
|
||||
|
||||
|
@ -125,12 +125,41 @@ MinecraftProcess::MinecraftProcess(InstancePtr inst, QString user, QString sessi
|
||||
// console window
|
||||
void MinecraftProcess::on_stdErr()
|
||||
{
|
||||
emit log(readAllStandardError(), MessageLevel::Error);
|
||||
QByteArray data = readAllStandardError();
|
||||
QString str = m_err_leftover + QString::fromLocal8Bit(data);
|
||||
m_err_leftover.clear();
|
||||
QStringList lines = str.split("\n");
|
||||
bool complete = str.endsWith("\n");
|
||||
|
||||
for(int i = 0; i < lines.size() - 1; i++)
|
||||
{
|
||||
QString & line = lines[i];
|
||||
MessageLevel::Enum level = MessageLevel::Error;
|
||||
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("[WARNING]") || line.contains("[STDERR]"))
|
||||
level = MessageLevel::Error;
|
||||
emit log(lines[i].toLocal8Bit(), level);
|
||||
}
|
||||
if(!complete)
|
||||
m_err_leftover = lines.last();
|
||||
}
|
||||
|
||||
void MinecraftProcess::on_stdOut()
|
||||
{
|
||||
emit log(readAllStandardOutput(), MessageLevel::Message);
|
||||
QByteArray data = readAllStandardOutput();
|
||||
QString str = m_out_leftover + QString::fromLocal8Bit(data);
|
||||
m_out_leftover.clear();
|
||||
QStringList lines = str.split("\n");
|
||||
bool complete = str.endsWith("\n");
|
||||
|
||||
for(int i = 0; i < lines.size() - 1; i++)
|
||||
{
|
||||
QString & line = lines[i];
|
||||
emit log(lines[i].toLocal8Bit(), MessageLevel::Message);
|
||||
}
|
||||
if(!complete)
|
||||
m_out_leftover = lines.last();
|
||||
}
|
||||
|
||||
// exit handler
|
||||
|
Loading…
Reference in New Issue
Block a user