Added warn as a log level, also made error and critical throw
This commit is contained in:
@@ -22,8 +22,8 @@ using namespace Tourmaline::Systems;
|
|||||||
|
|
||||||
// This is what happens when it takes you 50 years to implement
|
// This is what happens when it takes you 50 years to implement
|
||||||
// reflections to a language
|
// reflections to a language
|
||||||
std::array<const std::string, 5> Logging::LogLevelToString{
|
std::array<const std::string, 6> Logging::LogLevelToString{
|
||||||
"Critical", "Error", "Info", "Debug", "Trace"};
|
"Critical", "Error", "Warning", "Info", "Debug", "Trace"};
|
||||||
std::fstream Logging::File;
|
std::fstream Logging::File;
|
||||||
|
|
||||||
void Logging::LogToFile(std::string 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
|
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);
|
throw std::runtime_error(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ public:
|
|||||||
enum class LogLevel {
|
enum class LogLevel {
|
||||||
Critical = 0,
|
Critical = 0,
|
||||||
Error = 1,
|
Error = 1,
|
||||||
Info = 2,
|
Warning = 2,
|
||||||
Debug = 3,
|
Info = 3,
|
||||||
Trace = 4
|
Debug = 4,
|
||||||
|
Trace = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
static void LogToFile(std::string File = "");
|
static void LogToFile(std::string File = "");
|
||||||
@@ -29,6 +30,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static std::fstream File;
|
static std::fstream File;
|
||||||
static std::array<const std::string, 5> LogLevelToString;
|
static std::array<const std::string, 6> LogLevelToString;
|
||||||
};
|
};
|
||||||
} // namespace Tourmaline::Systems
|
} // namespace Tourmaline::Systems
|
||||||
|
|||||||
Reference in New Issue
Block a user