Iguana 0.0.0
Implementation Guardian of Analysis Algorithms
Loading...
Searching...
No Matches
iguana::Logger Class Reference

#include <Logger.h>

Detailed Description

Simple logger service.

  • Each algorithm instance should own a Logger instance
  • The user may control the log level of each Logger, thus the log level of each algorithm
  • Errors and warnings print to stderr, whereas all other levels print to stdout

Definition at line 30 of file Logger.h.

Public Types

enum  Level {
  trace , debug , info , quiet ,
  warn , error , silent
}
 

Public Member Functions

 Logger (std::string_view name="log", Level const lev=DEFAULT_LEVEL, bool const enable_style=true)
 
void SetLevel (std::string_view lev)
 
void SetLevel (Level const lev)
 
Level GetLevel ()
 
void EnableStyle ()
 Enable styled log printouts, with color and emphasis.
 
void DisableStyle ()
 Disable styled log printout color and emphasis.
 
template<typename... VALUES>
void Trace (std::string_view message, const VALUES... vals) const
 Printout a log message at the trace level.
 
template<typename... VALUES>
void Debug (std::string_view message, const VALUES... vals) const
 Printout a log message at the debug level.
 
template<typename... VALUES>
void Info (std::string_view message, const VALUES... vals) const
 Printout a log message at the info level.
 
template<typename... VALUES>
void Warn (std::string_view message, const VALUES... vals) const
 Printout a log message at the warn level.
 
template<typename... VALUES>
void Error (std::string_view message, const VALUES... vals) const
 Printout a log message at the error level.
 
template<typename... VALUES>
void Print (Level const lev, std::string_view message, const VALUES... vals) const
 

Static Public Member Functions

static std::string Header (std::string_view message, int const width=50)
 

Static Public Attributes

static Level const DEFAULT_LEVEL = info
 The default log level.
 

Friends

class Object
 

Member Enumeration Documentation

◆ Level

These are the available log levels, from lowest to highest:

  • trace: the most verbose level, used for fine-grained printouts for each event
  • debug: less verbose printout, expected to be less frequent than trace
  • info: the least verbose printout; this is the default level
  • quiet: use this level to only allow warnings and errors, silencing all other printouts
  • warn: an issue that may or may not be critical
  • error: an issue that is likely critical
  • silent: use this level to silence all printouts (use it at your own risk!)

Definition at line 45 of file Logger.h.

Constructor & Destructor Documentation

◆ Logger()

iguana::Logger::Logger ( std::string_view name = "log",
Level const lev = DEFAULT_LEVEL,
bool const enable_style = true )
Parameters
namethe name of this logger instance, which will be include in all of its printouts
levthe log level
enable_styleif true, certain printouts will be styled with color and emphasis

◆ ~Logger()

iguana::Logger::~Logger ( )
inline

Definition at line 62 of file Logger.h.

Member Function Documentation

◆ Debug()

template<typename... VALUES>
void iguana::Logger::Debug ( std::string_view message,
const VALUES... vals ) const
inline

Printout a log message at the debug level.

See also
Logger::Print for more details

Definition at line 95 of file Logger.h.

◆ Error()

template<typename... VALUES>
void iguana::Logger::Error ( std::string_view message,
const VALUES... vals ) const
inline

Printout a log message at the error level.

See also
Logger::Print for more details

Definition at line 104 of file Logger.h.

◆ GetLevel()

Level iguana::Logger::GetLevel ( )

Get the current log level

Returns
the log level

◆ Header()

static std::string iguana::Logger::Header ( std::string_view message,
int const width = 50 )
static

Generate a header for a printout

Parameters
messagethe header message
widththe width of the header in number of characters
Returns
the header string

◆ Info()

template<typename... VALUES>
void iguana::Logger::Info ( std::string_view message,
const VALUES... vals ) const
inline

Printout a log message at the info level.

See also
Logger::Print for more details

Definition at line 98 of file Logger.h.

◆ Print()

template<typename... VALUES>
void iguana::Logger::Print ( Level const lev,
std::string_view message,
const VALUES... vals ) const
inline

Printout a log message at the specified level. The message will only print if lev is at least as high as the current level of this Logger instance, as set by Logger::SetLevel.

Parameters
levthe log level for this message
messagethe message to print; this may be a format string, as in fmt::format
valsvalues for the format string message

Definition at line 112 of file Logger.h.

◆ SetLevel() [1/2]

void iguana::Logger::SetLevel ( Level const lev)

Set the log level to this level. Log messages with a lower level will not be printed.

See also
Logger::Level for available levels.
Parameters
levthe log level

◆ SetLevel() [2/2]

void iguana::Logger::SetLevel ( std::string_view lev)

Set the log level to this level. Log messages with a lower level will not be printed.

See also
Logger::Level for available levels.
Parameters
levthe log level name

◆ Trace()

template<typename... VALUES>
void iguana::Logger::Trace ( std::string_view message,
const VALUES... vals ) const
inline

Printout a log message at the trace level.

See also
Logger::Print for more details

Definition at line 92 of file Logger.h.

◆ Warn()

template<typename... VALUES>
void iguana::Logger::Warn ( std::string_view message,
const VALUES... vals ) const
inline

Printout a log message at the warn level.

See also
Logger::Print for more details

Definition at line 101 of file Logger.h.

Friends And Related Symbol Documentation

◆ Object

friend class Object
friend

Definition at line 33 of file Logger.h.

Member Data Documentation

◆ DEFAULT_LEVEL

Level const iguana::Logger::DEFAULT_LEVEL = info
static

The default log level.

Definition at line 56 of file Logger.h.


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