Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
thorin::Log Class Reference

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

#include <thorin/util/log.h>

Public Types

enum class  Level {
  Error ,
  Warn ,
  Info ,
  Verbose ,
  Debug
}
 

Public Member Functions

 Log (const Flags &flags)
 
Getters
const Flagsflags () const
 
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.

See also
Formatted Output, Logging Macros
template<class... Args>
void log (Level level, Loc loc, const char *fmt, Args &&... args) const
 
template<class... Args>
void log (Level level, const char *file, uint16_t line, const char *fmt, Args &&... args)
 

Static Public Member Functions

Conversions
static std::string_view level2acro (Level)
 
static rang::fg level2color (Level level)
 

Detailed Description

Facility to log what you are doing.

See also
Formatted Output, Logging Macros

Definition at line 14 of file log.h.

Member Enumeration Documentation

◆ Level

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

Definition at line 19 of file log.h.

Constructor & Destructor Documentation

◆ Log()

thorin::Log::Log ( const Flags flags)
inline

Definition at line 16 of file log.h.

Member Function Documentation

◆ flags()

const Flags & thorin::Log::flags ( ) const
inline

Definition at line 23 of file log.h.

Referenced by log().

◆ level()

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

Definition at line 24 of file log.h.

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

◆ level2acro()

std::string_view thorin::Log::level2acro ( Level  level)
static

Definition at line 6 of file log.cpp.

References Debug, Error, Info, level(), Verbose, and Warn.

Referenced by log().

◆ level2color()

rang::fg thorin::Log::level2color ( Level  level)
static

Definition at line 17 of file log.cpp.

References Debug, Error, Info, level(), Verbose, and Warn.

Referenced by log().

◆ log() [1/2]

template<class... Args>
void thorin::Log::log ( Level  level,
const char *  file,
uint16_t  line,
const char *  fmt,
Args &&...  args 
)
inline

Definition at line 60 of file log.h.

References thorin::fmt(), level(), and log().

◆ log() [2/2]

template<class... Args>
void thorin::Log::log ( Level  level,
Loc  loc,
const char *  fmt,
Args &&...  args 
) const
inline

Definition at line 48 of file log.h.

References Error, flags(), thorin::fmt(), level(), level2acro(), level2color(), ostream(), thorin::print(), and Warn.

Referenced by log().

◆ operator bool()

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

Checks if Log::ostream_ is set.

Definition at line 29 of file log.h.

◆ ostream()

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

Definition at line 25 of file log.h.

Referenced by log(), and set().

◆ set() [1/2]

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

Definition at line 38 of file log.h.

◆ set() [2/2]

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

Definition at line 34 of file log.h.

References ostream().


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