MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::Log Class Reference

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

#include <mim/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 17 of file log.h.

Member Enumeration Documentation

◆ Level

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

Definition at line 22 of file log.h.

Constructor & Destructor Documentation

◆ Log()

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

Definition at line 19 of file log.h.

Member Function Documentation

◆ flags()

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

Definition at line 26 of file log.h.

Referenced by log().

◆ level()

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

Definition at line 27 of file log.h.

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

◆ level2acro()

std::string_view mim::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 mim::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 mim::Log::log ( Level level,
const char * file,
uint16_t line,
const char * fmt,
Args &&... args )
inline

Definition at line 63 of file log.h.

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

◆ log() [2/2]

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

Definition at line 51 of file log.h.

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

Referenced by log().

◆ operator bool()

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

Checks if Log::ostream_ is set.

Definition at line 32 of file log.h.

◆ ostream()

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

Definition at line 28 of file log.h.

Referenced by log(), and set().

◆ set() [1/2]

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

Definition at line 41 of file log.h.

◆ set() [2/2]

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

Definition at line 37 of file log.h.

References ostream().

Referenced by main().


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