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

Thread-safe logger with file and console output. More...

#include <Logger.h>

Classes

struct  Impl
 

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)
 
void Shutdown ()
 
void SetLevel (LogLevel level) noexcept
 
LogLevel GetLevel () const noexcept
 
void SetConsoleOutput (bool enable)
 
void SetFileOutput (bool enable)
 
void Flush ()
 
std::filesystem::path GetLogFilePath () const
 
template<typename... Args>
void Debug (std::format_string< Args... > fmt, Args... args)
 
template<typename... Args>
void Info (std::format_string< Args... > fmt, Args... args)
 
template<typename... Args>
void Warning (std::format_string< Args... > fmt, Args... args)
 
template<typename... Args>
void Error (std::format_string< Args... > fmt, Args... args)
 
template<typename... Args>
void Fatal (std::format_string< Args... > fmt, 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 ()
 

Detailed Description

Thread-safe logger with file and console output.

Templated entry points format with std::vformat (C++20). The minimum-level filter is checked through an atomic so the early-out path is lock-free.

Usage:

LOG_INFO("Application started");
LOG_ERROR("Failed to load file: {}", filename);
#define LOG_INFO(...)
Definition Logger.h:166
#define LOG_ERROR(...)
Definition Logger.h:168

Definition at line 57 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::format_string< Args... >  fmt,
Args...  args 
)
inline

Definition at line 84 of file Logger.h.

References MetaImGUI::Debug, and GetLevel().

◆ Debug() [2/2]

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

Definition at line 119 of file Logger.h.

References MetaImGUI::Debug, and GetLevel().

◆ Error() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Error ( std::format_string< Args... >  fmt,
Args...  args 
)
inline

Definition at line 105 of file Logger.h.

References MetaImGUI::Error, and GetLevel().

◆ Error() [2/2]

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

Definition at line 134 of file Logger.h.

References MetaImGUI::Error, and GetLevel().

◆ Fatal() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Fatal ( std::format_string< Args... >  fmt,
Args...  args 
)
inline

Definition at line 112 of file Logger.h.

References MetaImGUI::Fatal, and GetLevel().

◆ Fatal() [2/2]

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

Definition at line 139 of file Logger.h.

References MetaImGUI::Fatal, and GetLevel().

◆ Flush()

void MetaImGUI::Logger::Flush ( )

Definition at line 156 of file Logger.cpp.

◆ GetLevel()

LogLevel MetaImGUI::Logger::GetLevel ( ) const
inlinenoexcept

Definition at line 73 of file Logger.h.

Referenced by Debug(), Debug(), Error(), Error(), Fatal(), Fatal(), Info(), Info(), Warning(), and Warning().

◆ GetLogFilePath()

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

Definition at line 165 of file Logger.cpp.

◆ Info() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Info ( std::format_string< Args... >  fmt,
Args...  args 
)
inline

Definition at line 91 of file Logger.h.

References GetLevel(), and MetaImGUI::Info.

◆ Info() [2/2]

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

Definition at line 124 of file Logger.h.

References GetLevel(), and MetaImGUI::Info.

◆ Initialize()

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

Definition at line 105 of file Logger.cpp.

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

◆ Instance()

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

◆ 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)

Definition at line 146 of file Logger.cpp.

◆ SetFileOutput()

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

Definition at line 151 of file Logger.cpp.

◆ SetLevel()

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

Definition at line 69 of file Logger.h.

◆ Shutdown()

void MetaImGUI::Logger::Shutdown ( )

Definition at line 137 of file Logger.cpp.

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

◆ Warning() [1/2]

template<typename... Args>
void MetaImGUI::Logger::Warning ( std::format_string< Args... >  fmt,
Args...  args 
)
inline

Definition at line 98 of file Logger.h.

References GetLevel(), and MetaImGUI::Warning.

◆ Warning() [2/2]

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

Definition at line 129 of file Logger.h.

References GetLevel(), and MetaImGUI::Warning.


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