13namespace fs = std::filesystem;
32 explicit operator bool()
const {
return ostream_; }
42 max_level_ = max_level;
51 template<
class... Args>
void log(
Level level, Loc loc,
const char*
fmt, Args&&... args)
const {
52 if (ostream_ &&
level <= max_level_) {
53 std::ostringstream oss;
57#ifdef MIM_ENABLE_CHECKS
63 template<
class... Args>
void log(
Level level,
const char* file, uint16_t line,
const char*
fmt, Args&&... args) {
64 auto path = fs::path(file);
65 log(
level, Loc(&path, line),
fmt, std::forward<Args&&>(args)...);
77 std::ostream* ostream_ =
nullptr;
87#define ELOG(...) log().log(mim::Log::Level::Error, __FILE__, __LINE__, __VA_ARGS__)
88#define WLOG(...) log().log(mim::Log::Level::Warn, __FILE__, __LINE__, __VA_ARGS__)
89#define ILOG(...) log().log(mim::Log::Level::Info, __FILE__, __LINE__, __VA_ARGS__)
90#define VLOG(...) log().log(mim::Log::Level::Verbose, __FILE__, __LINE__, __VA_ARGS__)
93#define DLOG(...) log().log(mim::Log::Level::Debug, __FILE__, __LINE__, __VA_ARGS__)
95#define DLOG(...) dummy()
Facility to log what you are doing.
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.