14namespace fs = std::filesystem;
33 explicit operator bool()
const {
return ostream_; }
43 max_level_ = max_level;
52 template<
class... Args>
53 void log(
Level level, Loc loc, std::format_string<Args...> fmt, Args&&... args)
const {
54 if (ostream_ &&
level <= max_level_) {
57 std::println(
ostream(), fmt, std::forward<Args>(args)...);
58#ifdef MIM_ENABLE_CHECKS
64 template<
class... Args>
65 void log(
Level level,
const char* file, uint16_t line, std::format_string<Args...> fmt, Args&&... args) {
66 auto path = fs::path(file);
67 log(
level, Loc(&path, line), fmt, std::forward<Args>(args)...);
79 std::ostream* ostream_ =
nullptr;
88#define ELOG(...) log().log(mim::Log::Level::Error, __FILE__, __LINE__, __VA_ARGS__)
89#define WLOG(...) log().log(mim::Log::Level::Warn, __FILE__, __LINE__, __VA_ARGS__)
90#define ILOG(...) log().log(mim::Log::Level::Info, __FILE__, __LINE__, __VA_ARGS__)
91#define VLOG(...) log().log(mim::Log::Level::Verbose, __FILE__, __LINE__, __VA_ARGS__)
94#define DLOG(...) log().log(mim::Log::Level::Debug, __FILE__, __LINE__, __VA_ARGS__)
95#define TLOG(...) log().log(mim::Log::Level::Trace, __FILE__, __LINE__, __VA_ARGS__)
97#define DLOG(...) log()
98#define TLOG(...) log()
static char level2acro(Level)
static fe::term::FG level2color(Level level)
std::ostream & ostream() const
const Flags & flags() const
Log & set(std::ostream *ostream)
void log(Level level, Loc loc, std::format_string< Args... > fmt, Args &&... args) const
Log & set(Level max_level)
void log(Level level, const char *file, uint16_t line, std::format_string< Args... > fmt, Args &&... args)
Compiler switches that must be saved and looked up in later phases of compilation.