8#include <source_location>
45 explicit operator bool()
const {
return ostream_; }
55 max_level_ = max_level;
61 template<
class... Args>
64 requires std::convertible_to<const S&, std::string_view>
65 consteval FmtLoc(
const S&
fmt, std::source_location
loc = std::source_location::current())
70 std::source_location
loc;
75 template<
class... Args>
81 template<
class... Args>
83 if (ostream_ &&
level <= max_level_) emit(
level, loc, fmt, std::forward<Args>(args)...);
87 template<
class... Args>
89 if (ostream_ &&
level <= max_level_)
90 emit(
level, std::format(
"{}:{}", where.file_name(), where.line()), fmt, std::forward<Args>(args)...);
94 template<
class... Args>
119 template<
class... Args>
void d(
Fmt<Args...>, Args&&...)
const {}
120 template<
class... Args>
void t(
Fmt<Args...>, Args&&...)
const {}
140 template<
class W,
class... Args>
142 auto oss = std::ostringstream();
149 std::ostream* ostream_ =
nullptr;
Collects diagnostics and hands each to the Diag that lays it out.
Facility to log what you are doing.
Log & set(std::ostream *ostream)
void e(Fmt< Args... > fmt, Args &&... args) const
FmtLoc< std::type_identity_t< Args >... > Fmt
Puts the Args of a Log::FmtLoc parameter into a non-deduced context, so that they are deduced from th...
static term::FG level2color(Level level)
void d(Fmt< Args... > fmt, Args &&... args) const
static char level2acro(Level level)
void t(Fmt< Args... > fmt, Args &&... args) const
Log & set(Level max_level)
void log(Level level, Loc loc, cite_string< Args... > fmt, Args &&... args) const
void log(Level level, std::source_location where, cite_string< Args... > fmt, Args &&... args) const
A std::source_location is no Loc: it points into your source, which has no fe::Src.
void w(Fmt< Args... > fmt, Args &&... args) const
void v(Fmt< Args... > fmt, Args &&... args) const
void log(Level level, Fmt< Args... > fmt, Args &&... args) const
Points at the call site.
std::ostream & ostream() const
void i(Fmt< Args... > fmt, Args &&... args) const
FG
Foreground colors that can be streamed into an std::ostream.
std::format_string< detail::cite_arg_t< Args >... > cite_string
A std::format_string whose backticks delimit a `citation` while those of its arguments are data.
FE_API void render_cite(std::ostream &os, std::string_view str, bool color)
Streams str into os, coloring each `citation` and dropping its backticks - or keeping them verbatim...
void breakpoint()
Raise a breakpoint in the debugger.
Location within a Src: the half-open byte range [Loc::begin, Loc::end).
A cite_string that remembers where it was written.
cite_string< Args... > fmt
consteval FmtLoc(const S &fmt, std::source_location loc=std::source_location::current())