29 explicit operator bool()
const {
return ostream_; }
39 max_level_ = max_level;
48 template<
class... Args>
void log(
Level level, Loc loc,
const char*
fmt, Args&&... args)
const {
49 if (ostream_ &&
level <= max_level_) {
50 std::ostringstream oss;
54#ifdef THORIN_ENABLE_CHECKS
60 template<
class... Args>
void log(
Level level,
const char* file, uint16_t line,
const char*
fmt, Args&&... args) {
61 auto path = fs::path(file);
62 log(
level, Loc(&path, line),
fmt, std::forward<Args&&>(args)...);
74 std::ostream* ostream_ =
nullptr;
84#define ELOG(...) log().log(thorin::Log::Level::Error, __FILE__, __LINE__, __VA_ARGS__)
85#define WLOG(...) log().log(thorin::Log::Level::Warn, __FILE__, __LINE__, __VA_ARGS__)
86#define ILOG(...) log().log(thorin::Log::Level::Info, __FILE__, __LINE__, __VA_ARGS__)
87#define VLOG(...) log().log(thorin::Log::Level::Verbose, __FILE__, __LINE__, __VA_ARGS__)
90#define DLOG(...) log().log(thorin::Log::Level::Debug, __FILE__, __LINE__, __VA_ARGS__)
92#define DLOG(...) dummy()
Facility to log what you are doing.
static std::string_view level2acro(Level)
void log(Level level, const char *file, uint16_t line, const char *fmt, Args &&... args)
static rang::fg level2color(Level level)
std::ostream & ostream() const
const Flags & flags() const
void log(Level level, Loc loc, const char *fmt, Args &&... args) const
Log & set(std::ostream *ostream)
Log & set(Level max_level)
std::ostream & print(std::ostream &os, const char *s)
Base case.
std::string fmt(const char *s, Args &&... args)
Wraps thorin::print to output a formatted std:string.
Compiler switches that must be saved and looked up in later phases of compilation.