diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-05-11 22:21:37 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-06-30 07:16:20 +0200 |
commit | 34ddfc7ecc2b0450b3d501e65cb4203ac747ed42 (patch) | |
tree | c53d32ac89aa996347901ea64f25909231a75895 /logic/MessageLevel.cpp | |
parent | d14a61b0df38d150e1449b19b7eee411e91e5211 (diff) | |
download | MultiMC-34ddfc7ecc2b0450b3d501e65cb4203ac747ed42.tar MultiMC-34ddfc7ecc2b0450b3d501e65cb4203ac747ed42.tar.gz MultiMC-34ddfc7ecc2b0450b3d501e65cb4203ac747ed42.tar.lz MultiMC-34ddfc7ecc2b0450b3d501e65cb4203ac747ed42.tar.xz MultiMC-34ddfc7ecc2b0450b3d501e65cb4203ac747ed42.zip |
GH-1053 base process and launch refactor, part 1
Diffstat (limited to 'logic/MessageLevel.cpp')
-rw-r--r-- | logic/MessageLevel.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/logic/MessageLevel.cpp b/logic/MessageLevel.cpp new file mode 100644 index 00000000..a5191290 --- /dev/null +++ b/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; +} |