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::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 37 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 34 of file log.cc.

◆ ~LogManager()

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

Definition at line 37 of file log.cc.

References log_stream_.

Member Function Documentation

◆ instance()

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

◆ 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 43 of file log.cc.

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

Referenced by yaze::editor::SettingsEditor::DrawAIAgentSettings(), and 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 74 of file log.cc.

References all_categories_enabled_, enabled_categories_, yaze::util::FATAL, log_stream_, and min_level_.

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

◆ SetLogLevel()

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

Runtime log level control (for debug card)

Definition at line 68 of file log.h.

References min_level_.

Referenced by yaze::editor::DungeonEditorV2::DrawDebugControlsCard().

◆ GetLogLevel()

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

Definition at line 69 of file log.h.

References min_level_.

Referenced by yaze::editor::DungeonEditorV2::DrawDebugControlsCard().

◆ EnableDebugLogging()

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

Toggle debug logging on/off at runtime.

Definition at line 74 of file log.h.

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

Referenced by yaze::editor::DungeonEditorV2::DrawDebugControlsCard().

◆ DisableDebugLogging()

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

Definition at line 75 of file log.h.

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

Referenced by yaze::editor::DungeonEditorV2::DrawDebugControlsCard().

◆ IsDebugEnabled()

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

Definition at line 76 of file log.h.

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

Referenced by yaze::editor::DungeonEditorV2::DrawDebugControlsCard().

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 84 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 85 of file log.h.

Referenced by configure(), and log().

◆ log_stream_

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

Definition at line 88 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 89 of file log.h.

Referenced by configure().


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