R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
logger::Logger Class Reference

Thread-safe logging system with timestamps and source location. More...

#include <Logger.hpp>

Collaboration diagram for logger::Logger:
Collaboration graph

Static Public Member Functions

static void setLevel (Level level)
 Set minimum log level (messages below this level are ignored)
 
static void setColors (bool enable)
 Enable or disable colored output.
 
static void log (Level level, const char *file, int line, const std::string &message)
 Log a message with source location.
 
template<typename... Args>
static void logf (Level level, const char *file, int line, Args &&...args)
 Log a message with formatted arguments.
 

Static Private Member Functions

static std::string getBasename (const char *filePath)
 Extract basename from file path.
 
static std::string getTimestamp ()
 Get current timestamp with milliseconds.
 
static const char * getLevelColor (Level level)
 Get color for log level.
 
static const char * getLevelString (Level level)
 Get string representation of log level.
 

Static Private Attributes

static std::mutex _mutex
 
static Level _minLevel = Level::DEBUG
 
static bool _enableColors = true
 

Detailed Description

Thread-safe logging system with timestamps and source location.

Definition at line 50 of file Logger.hpp.

Member Function Documentation

◆ getBasename()

static std::string logger::Logger::getBasename ( const char *  filePath)
inlinestaticprivate

Extract basename from file path.

Definition at line 59 of file Logger.hpp.

Referenced by log().

◆ getLevelColor()

static const char * logger::Logger::getLevelColor ( Level  level)
inlinestaticprivate

◆ getLevelString()

static const char * logger::Logger::getLevelString ( Level  level)
inlinestaticprivate

Get string representation of log level.

Definition at line 112 of file Logger.hpp.

References logger::CRITICAL, logger::DEBUG, logger::ERROR, logger::INFO, and logger::WARNING.

Referenced by log().

◆ getTimestamp()

static std::string logger::Logger::getTimestamp ( )
inlinestaticprivate

Get current timestamp with milliseconds.

Definition at line 68 of file Logger.hpp.

Referenced by log().

◆ log()

static void logger::Logger::log ( Level  level,
const char *  file,
int  line,
const std::string &  message 
)
inlinestatic

Log a message with source location.

Definition at line 143 of file Logger.hpp.

References _enableColors, _minLevel, _mutex, logger::Colors::BOLD_WHITE, logger::Colors::CYAN, getBasename(), getLevelColor(), getLevelString(), getTimestamp(), and logger::Colors::RESET.

Referenced by logf().

Here is the call graph for this function:

◆ logf()

template<typename... Args>
static void logger::Logger::logf ( Level  level,
const char *  file,
int  line,
Args &&...  args 
)
inlinestatic

Log a message with formatted arguments.

Definition at line 167 of file Logger.hpp.

References _minLevel, and log().

Here is the call graph for this function:

◆ setColors()

static void logger::Logger::setColors ( bool  enable)
inlinestatic

Enable or disable colored output.

Definition at line 138 of file Logger.hpp.

References _enableColors.

◆ setLevel()

static void logger::Logger::setLevel ( Level  level)
inlinestatic

Set minimum log level (messages below this level are ignored)

Definition at line 133 of file Logger.hpp.

References _minLevel.

Member Data Documentation

◆ _enableColors

bool logger::Logger::_enableColors = true
inlinestaticprivate

Definition at line 54 of file Logger.hpp.

Referenced by getLevelColor(), log(), and setColors().

◆ _minLevel

Level logger::Logger::_minLevel = Level::DEBUG
inlinestaticprivate

Definition at line 53 of file Logger.hpp.

Referenced by log(), logf(), and setLevel().

◆ _mutex

std::mutex logger::Logger::_mutex
inlinestaticprivate

Definition at line 52 of file Logger.hpp.

Referenced by log().


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