yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::util::LogManager Class Reference

A singleton that manages all logging configuration and output. More...

#include <log.h>

Public Member Functions

 LogManager (const LogManager &)=delete
 
void operator= (const LogManager &)=delete
 
void configure (LogLevel level, const std::string &file_path, const std::set< std::string > &categories)
 Configures the logging system.
 
void log (LogLevel level, absl::string_view category, absl::string_view message)
 The primary logging function.
 
void SetLogLevel (LogLevel level)
 Runtime log level control (for debug card)
 
LogLevel GetLogLevel () const
 
void EnableDebugLogging ()
 Toggle debug logging on/off at runtime.
 
void DisableDebugLogging ()
 
bool IsDebugEnabled () const
 

Static Public Member Functions

static LogManagerinstance ()
 

Private Member Functions

 LogManager ()
 
 ~LogManager ()
 

Private Attributes

std::atomic< LogLevelmin_level_
 
std::set< std::string > enabled_categories_
 
std::set< std::string > disabled_categories_
 
std::atomic< bool > all_categories_enabled_
 
std::ofstream log_stream_
 
std::string log_file_path_
 

Detailed Description

A singleton that manages all logging configuration and output.

It is designed to be configured once at application startup, typically from command-line arguments. It supports filtering by level and category, and can direct output to stderr (default) or a specified file.

Definition at line 33 of file log.h.

Constructor & Destructor Documentation

◆ LogManager() [1/2]

yaze::util::LogManager::LogManager ( const LogManager & )
delete

◆ LogManager() [2/2]

yaze::util::LogManager::LogManager ( )
private

Definition at line 36 of file log.cc.

◆ ~LogManager()

yaze::util::LogManager::~LogManager ( )
private

Definition at line 39 of file log.cc.

References log_stream_.

Member Function Documentation

◆ instance()

LogManager & yaze::util::LogManager::instance ( )
static

Definition at line 31 of file log.cc.

References instance().

Referenced by instance(), yaze::util::logf(), yaze::util::logf(), yaze::emu::Spc700::LogInstruction(), and main().

Here is the call graph for this function:

◆ operator=()

void yaze::util::LogManager::operator= ( const LogManager & )
delete

◆ configure()

void yaze::util::LogManager::configure ( LogLevel level,
const std::string & file_path,
const std::set< std::string > & categories )

Configures the logging system.

Parameters
levelThe minimum log level to record.
file_pathThe path to the log file. If empty, logs to stderr.
categoriesA set of specific categories to enable. If empty, all categories are enabled.

Definition at line 45 of file log.cc.

References all_categories_enabled_, disabled_categories_, enabled_categories_, log_file_path_, log_stream_, and min_level_.

Referenced by main().

◆ log()

void yaze::util::LogManager::log ( LogLevel level,
absl::string_view category,
absl::string_view message )

The primary logging function.

Parameters
levelThe severity level of the message.
categoryThe category of the message (e.g., "Graphics", "Agent").
messageThe formatted log message.

Definition at line 97 of file log.cc.

References all_categories_enabled_, disabled_categories_, enabled_categories_, yaze::util::FATAL, yaze::core::FeatureFlags::get(), yaze::core::FeatureFlags::Flags::kLogToConsole, log_stream_, and min_level_.

Referenced by yaze::util::logf(), yaze::util::logf(), and yaze::emu::Spc700::LogInstruction().

Here is the call graph for this function:

◆ SetLogLevel()

void yaze::util::LogManager::SetLogLevel ( LogLevel level)
inline

Runtime log level control (for debug card)

Definition at line 64 of file log.h.

References min_level_.

◆ GetLogLevel()

LogLevel yaze::util::LogManager::GetLogLevel ( ) const
inline

Definition at line 65 of file log.h.

References min_level_.

◆ EnableDebugLogging()

void yaze::util::LogManager::EnableDebugLogging ( )
inline

Toggle debug logging on/off at runtime.

Definition at line 70 of file log.h.

References min_level_, and yaze::util::YAZE_DEBUG.

◆ DisableDebugLogging()

void yaze::util::LogManager::DisableDebugLogging ( )
inline

Definition at line 71 of file log.h.

References yaze::util::INFO, and min_level_.

◆ IsDebugEnabled()

bool yaze::util::LogManager::IsDebugEnabled ( ) const
inline

Definition at line 72 of file log.h.

References min_level_, and yaze::util::YAZE_DEBUG.

Member Data Documentation

◆ min_level_

std::atomic<LogLevel> yaze::util::LogManager::min_level_
private

◆ enabled_categories_

std::set<std::string> yaze::util::LogManager::enabled_categories_
private

Definition at line 82 of file log.h.

Referenced by configure(), and log().

◆ disabled_categories_

std::set<std::string> yaze::util::LogManager::disabled_categories_
private

Definition at line 83 of file log.h.

Referenced by configure(), and log().

◆ all_categories_enabled_

std::atomic<bool> yaze::util::LogManager::all_categories_enabled_
private

Definition at line 84 of file log.h.

Referenced by configure(), and log().

◆ log_stream_

std::ofstream yaze::util::LogManager::log_stream_
private

Definition at line 87 of file log.h.

Referenced by configure(), log(), and ~LogManager().

◆ log_file_path_

std::string yaze::util::LogManager::log_file_path_
private

Definition at line 88 of file log.h.

Referenced by configure().


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