13namespace fs = std::filesystem;
32 explicit operator bool()
const {
return ostream_; }
42 max_level_ = max_level;
51 template<
class... Args>
53 if (ostream_ &&
level <= max_level_) {
54 std::ostringstream oss;
58#ifdef MIM_ENABLE_CHECKS
64 template<
class... Args>
65 void log(
Level level,
const char* file, uint16_t line,
const char*
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;
89#define ELOG(...) log().log(mim::Log::Level::Error, __FILE__, __LINE__, __VA_ARGS__)
90#define WLOG(...) log().log(mim::Log::Level::Warn, __FILE__, __LINE__, __VA_ARGS__)
91#define ILOG(...) log().log(mim::Log::Level::Info, __FILE__, __LINE__, __VA_ARGS__)
92#define VLOG(...) log().log(mim::Log::Level::Verbose, __FILE__, __LINE__, __VA_ARGS__)
95#define DLOG(...) log().log(mim::Log::Level::Debug, __FILE__, __LINE__, __VA_ARGS__)
97#define DLOG(...) dummy()
void log(Level level, const char *file, uint16_t line, const char *fmt, Args &&... args)
std::ostream & ostream() const
const Flags & flags() const
Log & set(std::ostream *ostream)
void log(Level level, Loc loc, const char *fmt, Args &&... args) const
Log & set(Level max_level)
static std::string_view level2acro(Level)
static rang::fg level2color(Level level)
std::ostream & print(std::ostream &os, const char *s)
Base case.
std::string fmt(const char *s, Args &&... args)
Wraps mim::print to output a formatted std:string.
Compiler switches that must be saved and looked up in later phases of compilation.