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

◆ write_to_stream()

template<typename Entry >
void MayaFlux::Journal::ConsoleSink::write_to_stream ( std::ostream &  os,
const Entry &  entry 
)
inlineprivate

Definition at line 42 of file ConsoleSink.hpp.

43 {
44 if (m_colors_enabled) {
45 switch (entry.severity) {
46 case Severity::TRACE:
47 os << AnsiColors::Cyan;
48 break;
49 case Severity::DEBUG:
50 os << AnsiColors::Blue;
51 break;
52 case Severity::INFO:
54 break;
55 case Severity::WARN:
57 break;
58 case Severity::ERROR:
60 break;
61 case Severity::FATAL:
63 break;
64 case Severity::NONE:
65 default:
67 break;
68 }
69 }
70
71 os << "[" << Reflect::enum_to_string(entry.severity) << "]" << AnsiColors::Reset;
72
73 os << AnsiColors::Magenta << "[" << Reflect::enum_to_string(entry.component) << "]" << AnsiColors::Reset;
74
75 os << AnsiColors::Cyan << "[" << Reflect::enum_to_string(entry.context) << "]" << AnsiColors::Reset << " ";
76
77 if constexpr (std::is_same_v<Entry, JournalEntry>) {
78 os << entry.message;
79 if (entry.location.file_name() != nullptr) {
80 os << AnsiColors::BrightBlue << " (" << entry.location.file_name()
81 << ":" << entry.location.line() << ")" << AnsiColors::Reset;
82 }
83 } else {
84 os << entry.message;
85 if (entry.file_name != nullptr) {
86 os << AnsiColors::BrightBlue << " (" << entry.file_name
87 << ":" << entry.line << ")" << AnsiColors::Reset;
88 }
89 }
90
91 if (m_colors_enabled) {
93 }
94
95 os << '\n';
96 }
static constexpr std::string_view Yellow
Definition Ansi.hpp:21
static constexpr std::string_view BrightBlue
Definition Ansi.hpp:31
static constexpr std::string_view White
Definition Ansi.hpp:25
static constexpr std::string_view Blue
Definition Ansi.hpp:22
static constexpr std::string_view Reset
Definition Ansi.hpp:15
static constexpr std::string_view Green
Definition Ansi.hpp:20
static constexpr std::string_view BgRed
Definition Ansi.hpp:36
static constexpr std::string_view Cyan
Definition Ansi.hpp:24
static constexpr std::string_view BrightRed
Definition Ansi.hpp:28
static constexpr std::string_view Magenta
Definition Ansi.hpp:23
constexpr std::string_view enum_to_string(EnumType value) noexcept
Universal enum to string converter using magic_enum (original case)