![]() |
UtilsLite
Utilities for C++ programming
|
Class to handle console output with different styles and levels. More...
#include <Console.hxx>
Public Member Functions | |
Console ()=delete | |
Deleted default constructor. | |
Console (Console const &)=delete | |
Deleted copy constructor. | |
Console (ostream_type *stream=&std::cout, int level=4) | |
Constructor with stream and level parameters. | |
~Console () | |
Destructor. | |
void | change_level (int new_level) |
Change the message level. | |
void | changeLevel (int new_level) |
Change the message level. | |
void | change_stream (ostream_type *new_stream) |
Change the output stream. | |
void | changeStream (ostream_type *new_stream) |
Change the output stream. | |
int | get_level () const |
Get the current message level. | |
int | getLevel () const |
Get the current message level. | |
ostream_type * | get_stream () const |
Get the current output stream. | |
ostream_type * | getStream () const |
Get the current output stream. | |
void | flush () const |
Flush the output stream. | |
void | message (string_view msg, int msg_level=4) const |
Output a message at a specified level. | |
void | semaphore (unsigned ryg, string_view msg, int msg_level=0) const |
Output a semaphore message. | |
void | colors (unsigned c, string_view msg, int msg_level=0) const |
Output a message with specified colors. | |
void | warning (string_view msg) const |
Output a warning message. | |
void | error (string_view msg) const |
Output an error message. | |
void | fatal (string_view msg) const |
Output a fatal message. | |
void | black (string_view msg, int msg_level=0) const |
Output a message in black color. | |
void | red (string_view msg, int msg_level=0) const |
Output a message in red color. | |
void | green (string_view msg, int msg_level=0) const |
Output a message in green color. | |
void | yellow (string_view msg, int msg_level=0) const |
Output a message in yellow color. | |
void | blue (string_view msg, int msg_level=0) const |
Output a message in blue color. | |
void | magenta (string_view msg, int msg_level=0) const |
Output a message in magenta color. | |
void | cyan (string_view msg, int msg_level=0) const |
Output a message in cyan color. | |
void | gray (string_view msg, int msg_level=0) const |
Output a message in gray color. | |
void | black_reversed (string_view msg, int msg_level=0) const |
Output a message in black reversed color. | |
void | red_reversed (string_view msg, int msg_level=0) const |
Output a message in red reversed color. | |
void | green_reversed (string_view msg, int msg_level=0) const |
Output a message in green reversed color. | |
void | yellow_reversed (string_view msg, int msg_level=0) const |
Output a message in yellow reversed color. | |
void | blue_reversed (string_view msg, int msg_level=0) const |
Output a message in blue reversed color. | |
void | magenta_reversed (string_view msg, int msg_level=0) const |
Output a message in magenta reversed color. | |
void | cyan_reversed (string_view msg, int msg_level=0) const |
Output a message in cyan reversed color. | |
void | gray_reversed (string_view msg, int msg_level=0) const |
Output a message in gray reversed color. | |
void | set_message_style (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | setMessageStyle (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | set_warning_style (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | setWarningStyle (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | set_error_style (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | setErrorStyle (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | set_fatal_style (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | setFatalStyle (rang::style const &s, rang::fg const &f, rang::bg const &b) |
void | set_off () const |
void | setOff () const |
void | set_auto () const |
void | setAuto () const |
Class to handle console output with different styles and levels.
m_level
. The method change_level
set m_level
in the range from -1 to 4. Each print message has a level, if level is less or equal to m_level
the message is printed. Message with level=0 are high priority message that are always printed unless m_level
is set to -1 which suppress all message. The default for m_level
is 4 which means all messages are printed.
|
delete |
Deleted default constructor.
|
delete |
Deleted copy constructor.
|
explicit |
Constructor with stream and level parameters.
stream | Pointer to output stream (default is std::cout). |
level | Minimum message level to output (default is 4). |
|
inline |
Destructor.
void Utils::Console::black | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in black color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::black_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in black reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::blue | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in blue color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::blue_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in blue reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::change_level | ( | int | new_level | ) |
Change the message level.
new_level | New level for message output. |
The admissible levels runs from -1 up to 4.
|
inline |
Change the output stream.
new_stream | Pointer to the new output stream. |
|
inline |
|
inline |
void Utils::Console::colors | ( | unsigned | c, |
string_view | msg, | ||
int | msg_level = 0 ) const |
Output a message with specified colors.
c | Color code. |
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::cyan | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in cyan color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::cyan_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in cyan reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::error | ( | string_view | msg | ) | const |
Output an error message.
msg | The error message to output. |
void Utils::Console::fatal | ( | string_view | msg | ) | const |
Output a fatal message.
msg | The fatal message to output. |
|
inline |
Flush the output stream.
|
inline |
Get the current message level.
|
inline |
Get the current output stream.
|
inline |
|
inline |
void Utils::Console::gray | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in gray color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::gray_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in gray reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::green | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in green color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::green_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in green reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::magenta | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in magenta color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::magenta_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in magenta reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::message | ( | string_view | msg, |
int | msg_level = 4 ) const |
Output a message at a specified level.
msg | The message to output. |
msg_level | The level of the message (default is 4). |
void Utils::Console::red | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in red color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::red_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in red reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::semaphore | ( | unsigned | ryg, |
string_view | msg, | ||
int | msg_level = 0 ) const |
Output a semaphore message.
ryg | Semaphore indicator (red, yellow, green). |
msg | The message to output. |
msg_level | The level of the message (default is 0). |
|
inline |
Sets coloring to automatic mode. Enables automatic color control in terminals depending on the operating system.
|
inline |
Sets the error style.
s | The text style. |
f | The foreground color. |
b | The background color. |
|
inline |
Sets the fatal error style.
s | The text style. |
f | The foreground color. |
b | The background color. |
|
inline |
Sets the message style.
s | The text style (e.g., bold, underline). |
f | The foreground color of the text. |
b | The background color of the text. |
|
inline |
Disables coloring. Turns off color control in non-Windows terminals.
|
inline |
Sets the warning style.
s | The text style. |
f | The foreground color. |
b | The background color. |
|
inline |
Sets coloring to automatic mode. Enables automatic color control in terminals depending on the operating system.
set_auto
|
inline |
Sets the error style.
s | The text style. |
f | The foreground color. |
b | The background color. |
set_error_style
|
inline |
Sets the fatal error style.
s | The text style. |
f | The foreground color. |
b | The background color. |
set_fatal_style
|
inline |
Sets the message style using a higher-level function.
s | The text style. |
f | The foreground color. |
b | The background color. |
set_message_style
|
inline |
Disables coloring. Turns off color control in non-Windows terminals.
set_off
|
inline |
Sets the warning style.
s | The text style. |
f | The foreground color. |
b | The background color. |
set_warning_style
void Utils::Console::warning | ( | string_view | msg | ) | const |
Output a warning message.
msg | The warning message to output. |
void Utils::Console::yellow | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in yellow color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |
void Utils::Console::yellow_reversed | ( | string_view | msg, |
int | msg_level = 0 ) const |
Output a message in yellow reversed color.
msg | The message to output. |
msg_level | The level of the message (default is 0). |