summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmultimc/include/minecraftprocess.h2
-rw-r--r--libmultimc/src/minecraftprocess.cpp33
2 files changed, 33 insertions, 2 deletions
diff --git a/libmultimc/include/minecraftprocess.h b/libmultimc/include/minecraftprocess.h
index f6272183..ac4d6be2 100644
--- a/libmultimc/include/minecraftprocess.h
+++ b/libmultimc/include/minecraftprocess.h
@@ -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;
diff --git a/libmultimc/src/minecraftprocess.cpp b/libmultimc/src/minecraftprocess.cpp
index 1239bc3a..f1b63e3d 100644
--- a/libmultimc/src/minecraftprocess.cpp
+++ b/libmultimc/src/minecraftprocess.cpp
@@ -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