Hymn to Beauty
C++ 3D Engine
Log Class Reference

Logging class. More...

#include <Log.hpp>

Public Types

enum  Channel {
  DEFAULT = 0 , INFO , WARNING , ERR ,
  NUMBER_OF_CHANNELS
}
 

Public Member Functions

 Log (const Channel channel=DEFAULT)
 Constructor. More...
 
 ~Log ()
 Destructor. More...
 
Logoperator<< (const std::string &text)
 Output some text. More...
 
Logoperator<< (const int value)
 Output an integer. More...
 
Logoperator<< (const unsigned int value)
 Output an unsigned integer. More...
 
Logoperator<< (const unsigned long value)
 Output an unsigned long. More...
 
Logoperator<< (const unsigned long long value)
 Output an unsigned long long. More...
 
Logoperator<< (const float value)
 Output a float. More...
 
Logoperator<< (const double value)
 Output a double. More...
 
Logoperator<< (const time_t value)
 Output a time. More...
 
Logoperator<< (const glm::vec2 &value)
 Output a vec2. More...
 
Logoperator<< (const glm::vec3 &value)
 Output a vec3. More...
 
Logoperator<< (const glm::vec4 &value)
 Output a vec4. More...
 

Static Public Member Functions

static void SetupCallback (std::function< void(const Channel channel, const std::string &message)> callback)
 Setup callback. More...
 
static void ResetCallback ()
 Remove the callback function. More...
 
static void SetupFile (const std::string &filename)
 Setup file to log to. More...
 
static void CloseFile ()
 Close any open logging file. More...
 

Detailed Description

Logging class.

Usage:

Log() << "Testing: " << 5 << "\n";
Log(const Channel channel=DEFAULT)
Constructor.
Definition: Log.cpp:19

Member Enumeration Documentation

◆ Channel

Enumerator
DEFAULT 

Default channel.

INFO 

Information.

WARNING 

Warnings.

ERR 

Error.

NUMBER_OF_CHANNELS 

Maximum number of channels, ensure this is the last element of the enum if adding channels.

Constructor & Destructor Documentation

◆ Log()

Log::Log ( const Channel  channel = DEFAULT)
explicit

Constructor.

◆ ~Log()

Log::~Log ( )

Destructor.

Member Function Documentation

◆ CloseFile()

void Log::CloseFile ( )
static

Close any open logging file.

◆ operator<<() [1/11]

Log & Log::operator<< ( const double  value)

Output a double.

Parameters
valueValue to output.
Returns
The Log instance.

◆ operator<<() [2/11]

Log & Log::operator<< ( const float  value)

Output a float.

Parameters
valueValue to output.
Returns
The Log instance

◆ operator<<() [3/11]

Log & Log::operator<< ( const glm::vec2 &  value)

Output a vec2.

Parameters
valueValue to output.
Returns
The Log instance.

◆ operator<<() [4/11]

Log & Log::operator<< ( const glm::vec3 &  value)

Output a vec3.

Parameters
valueValue to output.
Returns
The Log instance.

◆ operator<<() [5/11]

Log & Log::operator<< ( const glm::vec4 &  value)

Output a vec4.

Parameters
valueValue to output.
Returns
The Log instance.

◆ operator<<() [6/11]

Log & Log::operator<< ( const int  value)

Output an integer.

Parameters
valueValue to output.
Returns
The Log instance

◆ operator<<() [7/11]

Log & Log::operator<< ( const std::string &  text)

Output some text.

Parameters
textText to output.
Returns
The Log instance

◆ operator<<() [8/11]

Log & Log::operator<< ( const time_t  value)

Output a time.

Formatted Y-m-d H:M:S.

Parameters
valueValue to output.
Returns
The Log instance

◆ operator<<() [9/11]

Log & Log::operator<< ( const unsigned int  value)

Output an unsigned integer.

Parameters
valueValue to output.
Returns
The Log instance.

◆ operator<<() [10/11]

Log & Log::operator<< ( const unsigned long long  value)

Output an unsigned long long.

Parameters
valueValue to output.
Returns
The Log instance.

◆ operator<<() [11/11]

Log & Log::operator<< ( const unsigned long  value)

Output an unsigned long.

Parameters
valueValue to output.
Returns
The Log instance.

◆ ResetCallback()

void Log::ResetCallback ( )
static

Remove the callback function.

◆ SetupCallback()

void Log::SetupCallback ( std::function< void(const Channel channel, const std::string &message)>  callback)
static

Setup callback.

Parameters
callbackCallback function to call whenever something is logged.
Returns
Whether the operation succeeded.

◆ SetupFile()

void Log::SetupFile ( const std::string &  filename)
static

Setup file to log to.

Parameters
filenameThe file to write to.

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