ASGE  3.2.0
Simple Game Framework in GL
Logging Namespace Reference

Classes

struct  EnumHasher
 
class  LoggerFactory
 
class  LoggerBase
 
class  StdOutLogger
 
class  FileLogger
 

Typedefs

using LoggingConfig_t = std::unordered_map< std::string, std::string >
 
using LoggerCreator = LoggerBase *(*)(const LoggingConfig_t &)
 

Enumerations

enum class  LogLevel : uint8_t {
  TRACE = 0 , DEBUG = 1 , INFO = 2 , WARN = 3 ,
  ERRORS = 4 , NONE = 5
}
 

Functions

std::string timestamp ()
 
LoggerFactorygetFactory ()
 
bool RegisterLogger (const std::string &name, LoggerCreator function_ptr)
 
LoggerBasegetLogger (const LoggingConfig_t &config={ { "type", "std_out" }, { "color", "" } })
 
void configure (const LoggingConfig_t &config)
 
bool logable (LogLevel level)
 
void log (const std::string &message, const LogLevel level)
 
void log (const std::string &message)
 
void TRACE (const std::string &message)
 
void INFO (const std::string &message)
 
void DEBUG (const std::string &message)
 
void WARN (const std::string &message)
 
void ERRORS (const std::string &message)
 

Variables

constexpr LogLevel LOG_LEVEL_CUTOFF = LogLevel::INFO
 
const bool logger_registered
 
const bool std_out_logger_registered
 
const bool file_logger_registered
 

Detailed Description

Use to log messages.

The universal logging system and its functionality resides here

Enumeration Type Documentation

◆ LogLevel

enum Logging::LogLevel : uint8_t
strong

The logging level to use This will filter out any messages below the current log level

Enumerator
DEBUG 

Enum value TRACE.

INFO 

Enum value DEBUG.

WARN 

Enum value INFO.

ERRORS 

Enum value WARN.

NONE 

Enum value ERRORS.

Definition at line 57 of file Logger.hpp.

Function Documentation

◆ DEBUG()

void Logging::DEBUG ( const std::string &  message)
inline

Logs the message for debug use

Parameters
message
See also
LogLevel::DEBUG

Definition at line 314 of file Logger.hpp.

◆ ERRORS()

void Logging::ERRORS ( const std::string &  message)
inline

Logs the message at ERROR level

Parameters
message
See also
LogLevel::ERROR

Definition at line 338 of file Logger.hpp.

◆ INFO()

void Logging::INFO ( const std::string &  message)
inline

Logs the message as informational

Parameters
message
See also
LogLevel::INFO

Definition at line 302 of file Logger.hpp.

◆ log() [1/2]

void Logging::log ( const std::string &  message)
inline

statically log manually without a level or maybe with a custom one

Parameters
message

Definition at line 281 of file Logger.hpp.

◆ log() [2/2]

void Logging::log ( const std::string &  message,
const LogLevel  level 
)
inline

statically log manually without the macros below

Parameters
message
level

Definition at line 274 of file Logger.hpp.

◆ logable()

bool Logging::logable ( LogLevel  level)
inline

checks to see if log level threshold is met

Parameters
levelthe requested log level

Definition at line 266 of file Logger.hpp.

◆ timestamp()

std::string Logging::timestamp ( )
inline

Creates a timestamp using GMT.

Returns
returns formatted to: 'year/mo/dy hr:mn:sc.xxxxxx'

Definition at line 94 of file Logger.hpp.

◆ TRACE()

void Logging::TRACE ( const std::string &  message)
inline

logs the message at TRACE level

Parameters
message
See also
LogLevel::TRACE

Definition at line 290 of file Logger.hpp.

◆ WARN()

void Logging::WARN ( const std::string &  message)
inline

Logs the message as a warning

Parameters
message
See also
LogLevel::WARN

Definition at line 326 of file Logger.hpp.

Variable Documentation

◆ file_logger_registered

const bool Logging::file_logger_registered
Initial value:
=
RegisterLogger("file", []([[maybe_unused]] const LoggingConfig_t& config) {
LoggerBase* l = new FileLogger(config);
return l;
})
bool RegisterLogger(const std::string &name, LoggerCreator function_ptr)
register your custom loggers here
Definition: Logger.hpp:239

registers the file logger

Definition at line 364 of file Logger.hpp.

◆ logger_registered

const bool Logging::logger_registered
Initial value:
=
RegisterLogger("", []([[maybe_unused]] const LoggingConfig_t& config) {
auto* l = new LoggerBase(config);
return l;
})

registers the null logger

Definition at line 348 of file Logger.hpp.

◆ std_out_logger_registered

const bool Logging::std_out_logger_registered
Initial value:
=
RegisterLogger("std_out", []([[maybe_unused]] const LoggingConfig_t& config) {
LoggerBase* l = new StdOutLogger(config);
return l;
})

registers the std out logger

Definition at line 356 of file Logger.hpp.