FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches
fe::Log Class Reference

Facility to log what you are doing. More...

#include <fe/log.h>

Classes

struct  FmtLoc
 A std::format_string that remembers where it was written. More...

Public Types

enum class  Level {
  Error ,
  Warn ,
  Info ,
  Verbose ,
  Debug ,
  Trace
}
template<class... Args>
using Fmt = FmtLoc<std::type_identity_t<Args>...>
 Puts the Args of a Log::FmtLoc parameter into a non-deduced context, so that they are deduced from the trailing arguments and the format string keeps capturing its call site.

Public Member Functions

Getters
Level level () const
std::ostream & ostream () const
 operator bool () const
 Checks if Log::ostream_ is set.
Setters
Logset (std::ostream *ostream)
Logset (Level max_level)
Log

Output fmt to Log::ostream; does nothing if Log::ostream is nullptr.

template<class... Args>
void log (Level level, Loc loc, std::format_string< Args... > fmt, Args &&... args) const
template<class... Args>
void log (Level level, std::source_location where, std::format_string< Args... > fmt, Args &&... args) const
 A std::source_location is no Loc: it points into your source, which has no fe::Src.
template<class... Args>
void log (Level level, Fmt< Args... > fmt, Args &&... args) const
 Points at the call site.
Level Shorthands

Log at a fixed Level, pointing at the call site.

template<class... Args>
void e (Fmt< Args... > fmt, Args &&... args) const
template<class... Args>
void w (Fmt< Args... > fmt, Args &&... args) const
template<class... Args>
void i (Fmt< Args... > fmt, Args &&... args) const
template<class... Args>
void v (Fmt< Args... > fmt, Args &&... args) const
Debug Shorthands

Vaporize to nothingness in Release build; the arguments are still evaluated.

template<class... Args>
void d (Fmt< Args... > fmt, Args &&... args) const
template<class... Args>
void t (Fmt< Args... > fmt, Args &&... args) const

Static Public Member Functions

Conversions
static char level2acro (Level level)
static term::FG level2color (Level level)

Public Attributes

Breakpoints
bool break_on_error = false
bool break_on_warn = false

Detailed Description

Facility to log what you are doing.

Definition at line 20 of file log.h.

Member Typedef Documentation

◆ Fmt

template<class... Args>
using fe::Log::Fmt = FmtLoc<std::type_identity_t<Args>...>

Puts the Args of a Log::FmtLoc parameter into a non-deduced context, so that they are deduced from the trailing arguments and the format string keeps capturing its call site.

Definition at line 62 of file log.h.

Member Enumeration Documentation

◆ Level

enum class fe::Log::Level
strong
Enumerator
Error 
Warn 
Info 
Verbose 
Debug 
Trace 

Definition at line 22 of file log.h.

Member Function Documentation

◆ d()

template<class... Args>
void fe::Log::d ( Fmt< Args... > fmt,
Args &&... args ) const
inline

Definition at line 112 of file log.h.

References Debug, and log().

◆ e()

template<class... Args>
void fe::Log::e ( Fmt< Args... > fmt,
Args &&... args ) const
inline

Definition at line 90 of file log.h.

References Error, and log().

◆ i()

template<class... Args>
void fe::Log::i ( Fmt< Args... > fmt,
Args &&... args ) const
inline

Definition at line 98 of file log.h.

References Info, and log().

◆ level()

Level fe::Log::level ( ) const
inline

Definition at line 26 of file log.h.

Referenced by level2acro(), level2color(), log(), log(), and log().

◆ level2acro()

char fe::Log::level2acro ( Level level)
inlinestatic

Definition at line 136 of file log.h.

References Debug, Error, Info, level(), Trace, fe::unreachable(), Verbose, and Warn.

◆ level2color()

term::FG fe::Log::level2color ( Level level)
inlinestatic

◆ log() [1/3]

template<class... Args>
void fe::Log::log ( Level level,
Fmt< Args... > fmt,
Args &&... args ) const
inline

Points at the call site.

Definition at line 81 of file log.h.

References fe::Log::FmtLoc< Args >::fmt, level(), fe::Log::FmtLoc< Args >::loc, and log().

◆ log() [2/3]

template<class... Args>
void fe::Log::log ( Level level,
Loc loc,
std::format_string< Args... > fmt,
Args &&... args ) const
inline

Definition at line 68 of file log.h.

References level().

Referenced by d(), e(), i(), log(), t(), v(), and w().

◆ log() [3/3]

template<class... Args>
void fe::Log::log ( Level level,
std::source_location where,
std::format_string< Args... > fmt,
Args &&... args ) const
inline

A std::source_location is no Loc: it points into your source, which has no fe::Src.

Definition at line 74 of file log.h.

References level().

◆ operator bool()

fe::Log::operator bool ( ) const
inlineexplicit

Checks if Log::ostream_ is set.

Definition at line 31 of file log.h.

◆ ostream()

std::ostream & fe::Log::ostream ( ) const
inline

Definition at line 27 of file log.h.

Referenced by set().

◆ set() [1/2]

Log & fe::Log::set ( Level max_level)
inline

Definition at line 40 of file log.h.

◆ set() [2/2]

Log & fe::Log::set ( std::ostream * ostream)
inline

Definition at line 36 of file log.h.

References ostream().

◆ t()

template<class... Args>
void fe::Log::t ( Fmt< Args... > fmt,
Args &&... args ) const
inline

Definition at line 116 of file log.h.

References log(), and Trace.

◆ v()

template<class... Args>
void fe::Log::v ( Fmt< Args... > fmt,
Args &&... args ) const
inline

Definition at line 102 of file log.h.

References log(), and Verbose.

◆ w()

template<class... Args>
void fe::Log::w ( Fmt< Args... > fmt,
Args &&... args ) const
inline

Definition at line 94 of file log.h.

References log(), and Warn.

Member Data Documentation

◆ break_on_error

bool fe::Log::break_on_error = false

Definition at line 129 of file log.h.

◆ break_on_warn

bool fe::Log::break_on_warn = false

Definition at line 130 of file log.h.


The documentation for this class was generated from the following file: