VOX
A little voxel engine
Loading...
Searching...
No Matches
Logger Class Reference

A class for logging messages to the console and to files. More...

#include <logger.hpp>

Collaboration diagram for Logger:
Collaboration graph

Public Types

enum  Level {
  CRITICAL = 0 , ERROR = 1 , WARNING = 2 , INFO = 3 ,
  DEBUG = 4 , TRACE = 5 , MAX = 6
}
 The different levels of logging. More...
 

Public Member Functions

 Logger ()
 Construct a new Logger object. More...
 
 Logger (const std::filesystem::path &path)
 Construct a new Logger object and open 5 different files for logging. If the files exist, they will be overwritten. More...
 
void configure (const std::filesystem::path &path)
 Open 5 different files for logging. If the files exist, they will be overwritten. More...
 
void setLevel (Level level)
 Set the minimum level of messages to log to the console. More...
 
Level level () const
 Return the minimum level of messages to log to the console. More...
 
void setTimestamp (bool enabled)
 Enable or disable timestamps. More...
 
Loggeroperator<< (Level level)
 Set the message level. More...
 
Loggeroperator<< (std::ostream &(*manipulator)(std::ostream &))
 Transfer a manipulator to the stringstream buffer waiting to be flushed. If the manipulator is std::endl, the buffer will be flushed. More...
 
template<typename T >
Loggeroperator<< (T const &arg)
 Transfer a argument to the stringstream buffer waiting to be flushed. More...
 

Detailed Description

A class for logging messages to the console and to files.

Member Enumeration Documentation

◆ Level

The different levels of logging.

Enumerator
CRITICAL 
ERROR 
WARNING 
INFO 
DEBUG 
TRACE 
MAX 

Constructor & Destructor Documentation

◆ Logger() [1/2]

Logger::Logger ( )

Construct a new Logger object.

◆ Logger() [2/2]

Logger::Logger ( const std::filesystem::path &  path)

Construct a new Logger object and open 5 different files for logging. If the files exist, they will be overwritten.

Parameters
pathThe path to the log files.
Exceptions
std::runtime_errorif a log file could not be opened.

Member Function Documentation

◆ configure()

void Logger::configure ( const std::filesystem::path &  path)

Open 5 different files for logging. If the files exist, they will be overwritten.

Parameters
pathThe path to the log files.
Exceptions
std::runtime_errorif a log file could not be opened.

◆ level()

Logger::Level Logger::level ( ) const

Return the minimum level of messages to log to the console.

◆ operator<<() [1/3]

Logger & Logger::operator<< ( Level  level)

Set the message level.

Parameters
levelThe level to set.
Exceptions
std::runtime_errorif a message is currently being logged.

◆ operator<<() [2/3]

Logger & Logger::operator<< ( std::ostream &(*)(std::ostream &)  manipulator)

Transfer a manipulator to the stringstream buffer waiting to be flushed. If the manipulator is std::endl, the buffer will be flushed.

Parameters
manipulatorThe manipulator to transfer.

◆ operator<<() [3/3]

template<typename T >
Logger & Logger::operator<< ( T const &  arg)
inline

Transfer a argument to the stringstream buffer waiting to be flushed.

Parameters
argThe argument to transfer.

◆ setLevel()

void Logger::setLevel ( Level  level)

Set the minimum level of messages to log to the console.

Parameters
levelThe level to set.

◆ setTimestamp()

void Logger::setTimestamp ( bool  enabled)

Enable or disable timestamps.

Parameters
enabledWhether or not to enable timestamps.

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