Files
prismlauncher-crack/launcher/MessageLevel.h
Rachel Powers d1b6d7c402 chore: Re-simplify IndexVersionType and MessageLevel with c++20
This sets our compiler requirements to gcc 11 and clang 13. If we
forgo the use of `using enum` we can drop to gcc 10 and clang 10 but
that means using `MessageLevel::Enum::Unknown` for direct enum access

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
2025-12-11 09:59:33 -07:00

45 lines
1.6 KiB
C++

#pragma once
#include <qlogging.h>
#include <QString>
#include <compare>
/**
* @brief the MessageLevel Enum
* defines what level a log message is
*/
struct MessageLevel {
enum class Enum {
Unknown, /**< No idea what this is or where it came from */
StdOut, /**< Undetermined stderr messages */
StdErr, /**< Undetermined stdout messages */
Launcher, /**< Launcher Messages */
Trace, /**< Trace Messages */
Debug, /**< Debug Messages */
Info, /**< Info Messages */
Message, /**< Standard Messages */
Warning, /**< Warnings */
Error, /**< Errors */
Fatal, /**< Fatal Errors */
};
using enum Enum;
constexpr MessageLevel(Enum e = Unknown) : m_type(e) {}
static MessageLevel fromName(const QString& type);
static MessageLevel fromQtMsgType(const QtMsgType& type);
static MessageLevel fromLine(const QString& line);
inline bool isValid() const { return m_type != Unknown; }
std::strong_ordering operator<=>(const MessageLevel& other) const = default;
std::strong_ordering operator<=>(const MessageLevel::Enum& other) const { return m_type <=> other; }
explicit operator int() const { return static_cast<int>(m_type); }
explicit operator MessageLevel::Enum() { return m_type; }
private:
Enum m_type;
};
/* Get message level from a line. Line is modified if it was successful. */
MessageLevel messageLevelFromLine(QString& line);
/* Get message level from a line from the launcher log. Line is modified if it was successful. */
MessageLevel messageLevelFromLauncherLine(QString& line);