r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
utl::Logger Class Reference

Class for logging. More...

#include <Logger.hpp>

+ Collaboration diagram for utl::Logger:

Public Member Functions

 Logger (const Logger &)=delete
 
Loggeroperator= (const Logger &)=delete
 
 Logger (Logger &&)=delete
 
Loggeroperator= (Logger &&)=delete
 

Static Public Member Functions

static void init ()
 
template<typename Func >
static void logExecutionTime (const std::string &message, Func &&func)
 
static void log (const std::string &message, const LogLevel &logLevel)
 

Private Types

enum  ColorIndex : uint8_t { COLOR_ERROR , COLOR_INFO , COLOR_WARNING , COLOR_RESET }
 

Private Member Functions

 Logger ()=default
 
 ~Logger ()=default
 

Static Private Member Functions

static const char * getColorForDuration (const float duration)
 
static std::string formatLogMessage (LogLevel level, const std::string &message)
 

Static Private Attributes

static constexpr std::array< const char *, 4 > LOG_LEVEL_COLOR
 
static constexpr std::array< const char *, 2 > LOG_LEVEL_STRING = {"INFO", "WARNING"}
 

Detailed Description

Class for logging.

Definition at line 28 of file Logger.hpp.

Member Enumeration Documentation

◆ ColorIndex

enum utl::Logger::ColorIndex : uint8_t
private
Enumerator
COLOR_ERROR 
COLOR_INFO 
COLOR_WARNING 
COLOR_RESET 

Definition at line 58 of file Logger.hpp.

Constructor & Destructor Documentation

◆ Logger() [1/3]

utl::Logger::Logger ( const Logger & )
delete

◆ Logger() [2/3]

utl::Logger::Logger ( Logger && )
delete

◆ Logger() [3/3]

utl::Logger::Logger ( )
privatedefault

◆ ~Logger()

utl::Logger::~Logger ( )
privatedefault

Member Function Documentation

◆ formatLogMessage()

static std::string utl::Logger::formatLogMessage ( LogLevel level,
const std::string & message )
inlinestaticnodiscardprivate

Definition at line 85 of file Logger.hpp.

References LOG_LEVEL_STRING.

Referenced by log(), and logExecutionTime().

+ Here is the caller graph for this function:

◆ getColorForDuration()

static const char * utl::Logger::getColorForDuration ( const float duration)
inlinestaticnodiscardprivate

Definition at line 78 of file Logger.hpp.

References COLOR_ERROR, COLOR_INFO, COLOR_WARNING, and LOG_LEVEL_COLOR.

Referenced by logExecutionTime().

+ Here is the caller graph for this function:

◆ init()

void utl::Logger::init ( )
static

Definition at line 7 of file logger.cpp.

Referenced by main(), and main().

+ Here is the caller graph for this function:

◆ log()

static void utl::Logger::log ( const std::string & message,
const LogLevel & logLevel )
inlinestatic

Definition at line 51 of file Logger.hpp.

References COLOR_INFO, COLOR_RESET, COLOR_WARNING, formatLogMessage(), utl::INFO, and LOG_LEVEL_COLOR.

Referenced by cli::Client::Client(), utl::PluginLoader::loadPlugin(), main(), main(), cli::ArgsHandler::ParseArgs(), srv::ArgsHandler::ParseArgs(), and srv::Server::Server().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logExecutionTime()

template<typename Func >
static void utl::Logger::logExecutionTime ( const std::string & message,
Func && func )
inlinestatic

Definition at line 39 of file Logger.hpp.

References COLOR_RESET, formatLogMessage(), getColorForDuration(), utl::INFO, and LOG_LEVEL_COLOR.

+ Here is the call graph for this function:

◆ operator=() [1/2]

Logger & utl::Logger::operator= ( const Logger & )
delete

◆ operator=() [2/2]

Logger & utl::Logger::operator= ( Logger && )
delete

Member Data Documentation

◆ LOG_LEVEL_COLOR

std::array<const char *, 4> utl::Logger::LOG_LEVEL_COLOR
staticconstexprprivate
Initial value:
= {
"\033[31m",
"\033[32m",
"\033[33m",
"\033[0m\n"
}

Definition at line 66 of file Logger.hpp.

Referenced by getColorForDuration(), log(), and logExecutionTime().

◆ LOG_LEVEL_STRING

std::array<const char *, 2> utl::Logger::LOG_LEVEL_STRING = {"INFO", "WARNING"}
staticconstexprprivate

Definition at line 73 of file Logger.hpp.

Referenced by formatLogMessage().


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