MetaImGUI 1.0.0
ImGui Application Template for C++20
Loading...
Searching...
No Matches
MetaImGUI::Logger Class Reference

Simple logging system with file and console output. More...

#include <Logger.h>

Public Member Functions

 Logger (const Logger &)=delete
 
Loggeroperator= (const Logger &)=delete
 
 Logger (Logger &&)=delete
 
Loggeroperator= (Logger &&)=delete
 
void Initialize (const std::filesystem::path &logFilePath="", LogLevel minLevel=LogLevel::Info)
 Initialize logger with optional log file.
 
void Shutdown ()
 Shutdown logger and flush buffers.
 
void SetLevel (LogLevel level)
 Set minimum log level.
 
LogLevel GetLevel () const
 Get current log level.
 
void SetConsoleOutput (bool enable)
 Enable/disable console output.
 
void SetFileOutput (bool enable)
 Enable/disable file output.
 
void Flush ()
 Flush log buffers.
 
std::filesystem::path GetLogFilePath () const
 Get log file path.
 
template<typename... Args>
void Debug (std::string_view format, Args &&... args)
 
template<typename... Args>
void Info (std::string_view format, Args &&... args)
 
template<typename... Args>
void Warning (std::string_view format, Args &&... args)
 
template<typename... Args>
void Error (std::string_view format, Args &&... args)
 
template<typename... Args>
void Fatal (std::string_view format, Args &&... args)
 
void Debug (std::string_view message)
 
void Info (std::string_view message)
 
void Warning (std::string_view message)
 
void Error (std::string_view message)
 
void Fatal (std::string_view message)
 

Static Public Member Functions

static LoggerInstance ()
 Get singleton instance.
 

Detailed Description

Simple logging system with file and console output.

Logger provides thread-safe logging with configurable severity levels, timestamps, and output to both console and file.

Usage:

Logger::Instance().Info("Application started");
Logger::Instance().Error("Failed to load file: {}", filename);
LOG_DEBUG("Debug message");
LOG_INFO("Info message");
LOG_WARNING("Warning message");
LOG_ERROR("Error message");
#define LOG_INFO(...)
Definition Logger.h:218
#define LOG_DEBUG(...)
Definition Logger.h:217
#define LOG_ERROR(...)
Definition Logger.h:220
#define LOG_WARNING(...)
Definition Logger.h:219
void Info(std::string_view format, Args &&... args)
Definition Logger.h:120
void Error(std::string_view format, Args &&... args)
Definition Logger.h:130
static Logger & Instance()
Get singleton instance.
Definition Logger.cpp:34

Definition at line 58 of file Logger.h.

Constructor & Destructor Documentation

◆ Logger() [1/2]

MetaImGUI::Logger::Logger ( const Logger )
delete

◆ Logger() [2/2]

MetaImGUI::Logger::Logger ( Logger &&  )
delete

Member Function Documentation

◆ Debug() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Debug ( std::string_view  format,
Args &&...  args 
)
inline

Definition at line 115 of file Logger.h.

References MetaImGUI::Debug.

◆ Debug() [2/2]

void MetaImGUI::Logger::Debug ( std::string_view  message)
inline

Definition at line 140 of file Logger.h.

References MetaImGUI::Debug.

◆ Error() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Error ( std::string_view  format,
Args &&...  args 
)
inline

Definition at line 130 of file Logger.h.

References MetaImGUI::Error.

◆ Error() [2/2]

void MetaImGUI::Logger::Error ( std::string_view  message)
inline

Definition at line 149 of file Logger.h.

References MetaImGUI::Error.

◆ Fatal() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Fatal ( std::string_view  format,
Args &&...  args 
)
inline

Definition at line 135 of file Logger.h.

References MetaImGUI::Fatal.

◆ Fatal() [2/2]

void MetaImGUI::Logger::Fatal ( std::string_view  message)
inline

Definition at line 152 of file Logger.h.

References MetaImGUI::Fatal.

◆ Flush()

void MetaImGUI::Logger::Flush ( )

Flush log buffers.

Definition at line 101 of file Logger.cpp.

◆ GetLevel()

LogLevel MetaImGUI::Logger::GetLevel ( ) const

Get current log level.

Definition at line 86 of file Logger.cpp.

◆ GetLogFilePath()

std::filesystem::path MetaImGUI::Logger::GetLogFilePath ( ) const

Get log file path.

Definition at line 110 of file Logger.cpp.

◆ Info() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Info ( std::string_view  format,
Args &&...  args 
)
inline

Definition at line 120 of file Logger.h.

References MetaImGUI::Info.

◆ Info() [2/2]

void MetaImGUI::Logger::Info ( std::string_view  message)
inline

Definition at line 143 of file Logger.h.

References MetaImGUI::Info.

◆ Initialize()

void MetaImGUI::Logger::Initialize ( const std::filesystem::path &  logFilePath = "",
LogLevel  minLevel = LogLevel::Info 
)

Initialize logger with optional log file.

Parameters
logFilePathPath to log file (empty to disable file logging)
minLevelMinimum log level to output

Definition at line 39 of file Logger.cpp.

Referenced by MetaImGUI::Application::Initialize().

◆ Instance()

Logger & MetaImGUI::Logger::Instance ( )
static

Get singleton instance.

Definition at line 34 of file Logger.cpp.

Referenced by MetaImGUI::Application::Initialize(), and MetaImGUI::Application::Shutdown().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ SetConsoleOutput()

void MetaImGUI::Logger::SetConsoleOutput ( bool  enable)

Enable/disable console output.

Definition at line 91 of file Logger.cpp.

◆ SetFileOutput()

void MetaImGUI::Logger::SetFileOutput ( bool  enable)

Enable/disable file output.

Definition at line 96 of file Logger.cpp.

◆ SetLevel()

void MetaImGUI::Logger::SetLevel ( LogLevel  level)

Set minimum log level.

Definition at line 81 of file Logger.cpp.

◆ Shutdown()

void MetaImGUI::Logger::Shutdown ( )

Shutdown logger and flush buffers.

Definition at line 72 of file Logger.cpp.

Referenced by MetaImGUI::Application::Shutdown().

◆ Warning() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Warning ( std::string_view  format,
Args &&...  args 
)
inline

Definition at line 125 of file Logger.h.

References MetaImGUI::Warning.

◆ Warning() [2/2]

void MetaImGUI::Logger::Warning ( std::string_view  message)
inline

Definition at line 146 of file Logger.h.

References MetaImGUI::Warning.


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