MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ announce()

void Lila::Commentator::announce ( LogLevel  level,
Emitter  source,
std::string_view  message,
std::source_location  location = std::source_location::current() 
)
inline

Announces a log message with full control.

Parameters
levelLog severity.
sourceEmitter subsystem.
messageLog message.
locationSource location (auto-filled).

Definition at line 116 of file Commentator.hpp.

118 {
119 if (level < m_min_level)
120 return;
121
122 std::lock_guard lock(m_mutex);
123
124 auto use_color = [this](std::string_view color_code) {
125 return m_colors_enabled ? color_code : "";
126 };
127
128 std::cout << " "; // 8 spaces indent
129
130 std::cout << use_color(Colors::BrightBlue)
131 << "▶ LILA "
132 << use_color(Colors::Reset);
133
134 std::cout << use_color(level_color(level))
135 << "|" << level_string(level) << "| "
136 << use_color(Colors::Reset);
137
138 std::cout << use_color(Colors::Cyan)
139 << emitter_string(source) << " → "
140 << use_color(Colors::Reset);
141
142 std::cout << message;
143
144 if (m_verbose || level >= LogLevel::ERROR) {
145 if (location.file_name() != nullptr) {
146 std::cout << use_color(Colors::BrightBlue)
147 << " (" << extract_filename(location.file_name())
148 << ":" << location.line() << ")"
149 << use_color(Colors::Reset);
150 }
151 }
152
153 std::cout << "\n";
154 }
static std::string_view extract_filename(const char *path)
Extracts the filename from a file path.
static constexpr std::string_view emitter_string(Emitter source)
Gets the string representation of an emitter.
static constexpr std::string_view level_string(LogLevel level)
Gets the string representation of a log level.
static constexpr std::string_view level_color(LogLevel level)
Gets the ANSI color code for a log level.
constexpr std::string_view Cyan
constexpr std::string_view BrightBlue
constexpr std::string_view Reset