diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-11-03 01:10:16 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-11-03 01:11:57 +0100 |
commit | f0b71f989ea798495ad80d1f059ae0a28514f9a2 (patch) | |
tree | 8551131b5ce3ccaa3c422f6635aefdbf6ca149ff /api/logic/MessageLevel.cpp | |
parent | ac66af6c13604a4eb2d36cc82417aa6753b84afe (diff) | |
download | MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar.gz MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar.lz MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar.xz MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.zip |
NOISSUE use LoggedProcess to work around issues with QProcess on macOS
Diffstat (limited to 'api/logic/MessageLevel.cpp')
-rw-r--r-- | api/logic/MessageLevel.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/api/logic/MessageLevel.cpp b/api/logic/MessageLevel.cpp new file mode 100644 index 00000000..a5191290 --- /dev/null +++ b/api/logic/MessageLevel.cpp @@ -0,0 +1,36 @@ +#include "MessageLevel.h" + +MessageLevel::Enum MessageLevel::getLevel(const QString& levelName) +{ + if (levelName == "MultiMC") + return MessageLevel::MultiMC; + else if (levelName == "Debug") + return MessageLevel::Debug; + else if (levelName == "Info") + return MessageLevel::Info; + else if (levelName == "Message") + return MessageLevel::Message; + else if (levelName == "Warning") + return MessageLevel::Warning; + else if (levelName == "Error") + return MessageLevel::Error; + else if (levelName == "Fatal") + return MessageLevel::Fatal; + // Skip PrePost, it's not exposed to !![]! + // Also skip StdErr and StdOut + else + return MessageLevel::Unknown; +} + +MessageLevel::Enum MessageLevel::fromLine(QString &line) +{ + // Level prefix + int endmark = line.indexOf("]!"); + if (line.startsWith("!![") && endmark != -1) + { + auto level = MessageLevel::getLevel(line.left(endmark).mid(3)); + line = line.mid(endmark + 2); + return level; + } + return MessageLevel::Unknown; +} |