Added warn as a log level, also made error and critical throw

This commit is contained in:
2026-01-06 01:31:00 +02:00
parent 6d9edc18b4
commit c36c3468bb
2 changed files with 9 additions and 7 deletions

View File

@@ -22,8 +22,8 @@ using namespace Tourmaline::Systems;
// This is what happens when it takes you 50 years to implement
// reflections to a language
std::array<const std::string, 5> Logging::LogLevelToString{
"Critical", "Error", "Info", "Debug", "Trace"};
std::array<const std::string, 6> Logging::LogLevelToString{
"Critical", "Error", "Warning", "Info", "Debug", "Trace"};
std::fstream Logging::File;
void Logging::LogToFile(std::string File) {
@@ -53,7 +53,8 @@ void Logging::Log(const std::string &message, const std::string &position,
Logging::File.flush(); // Terrible but necessary sadly
}
if (severity == Logging::LogLevel::Critical) {
// Error and Critical
if (severity < Logging::LogLevel::Warning) {
throw std::runtime_error(output);
}
}

View File

@@ -17,9 +17,10 @@ public:
enum class LogLevel {
Critical = 0,
Error = 1,
Info = 2,
Debug = 3,
Trace = 4
Warning = 2,
Info = 3,
Debug = 4,
Trace = 5
};
static void LogToFile(std::string File = "");
@@ -29,6 +30,6 @@ public:
private:
static std::fstream File;
static std::array<const std::string, 5> LogLevelToString;
static std::array<const std::string, 6> LogLevelToString;
};
} // namespace Tourmaline::Systems