Switched to Corrade's string over STL

This commit is contained in:
2026-03-07 14:44:29 +02:00
parent 55f12fcd69
commit 88d4695596
6 changed files with 85 additions and 79 deletions

View File

@@ -9,33 +9,35 @@
#ifndef GUARD_TOURMALINE_LOGGING_H
#define GUARD_TOURMALINE_LOGGING_H
#include "Corrade/Containers/Array.h"
#include "Corrade/Containers/String.h"
#include "Corrade/Containers/StringView.h"
#include "Corrade/Utility/Format.h"
#include <fstream>
#include <string_view>
namespace Tourmaline::Systems {
class Logging {
public:
enum class LogLevel {
Critical = 0,
Error = 1,
Warning = 2,
Info = 3,
Debug = 4,
Trace = 5
};
enum LogLevel { Critical, Error, Warning, Info, Debug, Trace };
static void LogToFile(std::string File = "");
static void Log(std::string_view message,
std::string_view position = "Unknown",
static void LogToFile(Corrade::Containers::String File = "");
static void Log(Corrade::Containers::StringView message,
Corrade::Containers::StringView position = "Unknown",
LogLevel severity = LogLevel::Info, bool assertion = true);
template <class... Args>
static void LogFormatted(const char *format,
Corrade::Containers::StringView position,
LogLevel severity, const Args &...args) {
Corrade::Containers::String formatted =
Corrade::Utility::format(format, args...);
Log(formatted, position, severity);
}
private:
static std::fstream File;
static Corrade::Containers::Array<
std::pair<const std::string, const std::string>>
LogLevelToString;
static const char *LogLevelToColour[LogLevel::Trace + 1];
static const char *LogLevelToString[LogLevel::Trace + 1];
};
} // namespace Tourmaline::Systems
#endif