MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Lila::Commentator Class Reference

Centralized, thread-safe logging and announcement system for Lila. More...

#include <Commentator.hpp>

+ Collaboration diagram for Lila::Commentator:

Public Member Functions

void set_level (LogLevel level)
 
void set_verbose (bool verbose)
 Enables or disables verbose output (shows source location).
 
void announce (LogLevel level, Emitter source, std::string_view message, std::source_location location=std::source_location::current())
 Announces a log message with full control.
 
void trace (Emitter source, std::string_view message, std::source_location location=std::source_location::current())
 Logs a TRACE-level message.
 
void debug (Emitter source, std::string_view message, std::source_location location=std::source_location::current())
 Logs a DEBUG-level message.
 
void info (Emitter source, std::string_view message, std::source_location location=std::source_location::current())
 Logs an INFO-level message.
 
void warn (Emitter source, std::string_view message, std::source_location location=std::source_location::current())
 Logs a WARN-level message.
 
void error (Emitter source, std::string_view message, std::source_location location=std::source_location::current())
 Logs an ERROR-level message.
 
void fatal (Emitter source, std::string_view message, std::source_location location=std::source_location::current())
 Logs a FATAL-level message.
 
 Commentator (const Commentator &)=delete
 
Commentatoroperator= (const Commentator &)=delete
 

Static Public Member Functions

static Commentatorinstance ()
 

Private Member Functions

 Commentator ()
 Initializes console color support (platform-specific).
 

Static Private Member Functions

static bool initialize_console_colors ()
 
static constexpr std::string_view level_color (LogLevel level)
 Gets the ANSI color code for a log level.
 
static constexpr std::string_view level_string (LogLevel level)
 Gets the string representation of a log level.
 
static constexpr std::string_view emitter_string (Emitter source)
 Gets the string representation of an emitter.
 
static std::string_view extract_filename (const char *path)
 Extracts the filename from a file path.
 

Private Attributes

std::mutex m_mutex
 
LogLevel m_min_level = LogLevel::INFO
 
bool m_verbose = false
 
bool m_colors_enabled
 

Detailed Description

Centralized, thread-safe logging and announcement system for Lila.

The Commentator class provides formatted, colorized, and categorized logging for all Lila subsystems. It supports log levels, verbosity, and source tagging, and is designed for both interactive and automated use.

Core Features

  • Singleton access via Commentator::instance()
  • Log level filtering and verbosity control
  • Colorized output (ANSI codes, auto-enabled on supported platforms)
  • Source location reporting (file, line) for verbose/error/fatal logs
  • Thread-safe logging (mutex-protected)
  • Macros for convenient logging (LILA_INFO, LILA_ERROR, etc.)

Usage Example

LILA_INFO(Lila::Emitter::SYSTEM, "Server started");
LILA_ERROR(Lila::Emitter::INTERPRETER, "Compilation failed");
Lila::Commentator::instance().set_level(Lila::LogLevel::DEBUG);
#define LILA_ERROR(emitter, msg)
#define LILA_INFO(emitter, msg)
void set_verbose(bool verbose)
Enables or disables verbose output (shows source location).
void set_level(LogLevel level)
static Commentator & instance()

Commentator is intended for internal use by Lila and its binaries.

Definition at line 86 of file Commentator.hpp.


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