Print messages into standard console.
More...
#include <ConsoleReporter.h>
Print messages into standard console.
Definition at line 28 of file ConsoleReporter.h.
◆ notify()
void hermes::ConsoleReporter::notify |
( |
const Message * |
m | ) |
|
|
finalvirtual |
Implements hermes::Sink.
Definition at line 43 of file ConsoleReporter.cpp.
44{
45 if (not _env_checked)
46 {
47 const char *env_color_p = std::getenv("ONE_HERMES_COLOR");
48 if (env_color_p)
49 {
50 auto env_color_str = std::string(env_color_p);
51 if ((env_color_str == "1") or (env_color_str == "ON"))
52 _is_colored = true;
53 }
54 _env_checked = true;
55 }
56
57 if (_is_colored)
58 {
59 switch (
m->get_severity())
60 {
62 std::cout << kTermColorRedTextCode << kTermBoldTextCode << kTermUnderlineTextCode;
63 break;
65 std::cout << kTermColorRedTextCode;
66 break;
68 std::cout << kTermColorOrangeTextCode;
69 break;
71 std::cout << kTermColorGreenTextCode;
72 break;
74 std::cout << kTermColorResetAllCode;
75 break;
76 };
77 }
78 for (uint32_t n = 0; n <
m->text()->
lines(); ++n)
79 {
80 std::cout <<
m->text()->line(n) << std::endl;
81 }
82 if (_is_colored)
83 {
84 std::cout << kTermColorResetAllCode;
85 }
86}
References hermes::ERROR, hermes::FATAL, hermes::INFO, m, hermes::VERBOSE, and hermes::WARN.
◆ set_colored_mode()
void hermes::ConsoleReporter::set_colored_mode |
( |
bool |
is_colored | ) |
|
|
inline |
The documentation for this struct was generated from the following files: