ConsoleSink ConsoleSinks are tightly linked to the std::cout object.
Colorize Messages
The library offers a quick way setting up your intended color (and style) table, based on any Record property. Here is a quick example which illustrates the setup:
22 makeConsoleTextStyleTableFor<Record_t>(
26 {
SevLvl::debug, { .textColor = Color::yellow, .bgColor = Color::gray } },
29 {
SevLvl::error, { .style = Style::bold, .textColor = Color::red, .bgColor = Color::yellow } },
30 {
SevLvl::fatal, { .style = Style::crossed, .textColor = Color::gray, .bgColor = Color::red } }
35 log() <<
"Hello, World!";
const SeverityLevel_t & severity() const noexcept
Const access to the severity level.
Definition: Record.hpp:284
Sink class for directly logging onto std::cout.
Definition: ConsoleSink.hpp:239
The central point of the whole library. Needs to be instantiated at least once.
Definition: Core.hpp:51
requires std::constructible_from< TSink, TArgs... > TSink & makeSink(TArgs &&... args)
Creates Sink and registers it at this Core instance.
Definition: Core.hpp:130
Manipulates the channel of the current RecordBuilder object.
Definition: RecordBuilder.hpp:31
Definition: PresetTypes.hpp:14
auto & gConsoleSink
Definition: ReadyToGo.hpp:19
Definition: BasicSink.hpp:22
Style
Definition: ConsoleSink.hpp:67
Color
Definition: ConsoleSink.hpp:45
◆ makeConsoleTextStyleTableFor()
template<Record TRecord, std::invocable< const TRecord & > TProjection, class TTable = std::unordered_map< std::remove_cvref_t<std::invoke_result_t<TProjection, const TRecord&>>, ConsoleTextStyle >>
auto sl::log::makeConsoleTextStyleTableFor |
( |
TProjection |
projection, |
|
|
TTable |
table |
|
) |
| |
The factory function for creating ConsoleTextStyleTable instances.
- Template Parameters
-
TRecord | The currently used Record type |
TProjection | The projection type |
TTable | The table type. The default type is of std::unordered_map. Users may exchange this with std::map. |
- Parameters
-
projection | The projection to a member of the currently used Record type |
table | The finally established container object |
- Returns
- Returns a newly created ConsoleTextStyleTable instance
This is the preferable way creating a ConsoleTextStyleTable object for a Record property, because the projection and the table type becomes strong checked via concept and therefore will provide much clearer feedback in cases of error, while creating ConsoleTextStyleTable objects manually will probably result in harder to read error message.
- Version
- since alpha-0.6
◆ operator<<()
std::ostream& sl::log::operator<< |
( |
std::ostream & |
out, |
|
|
const ConsoleTextStyle & |
style |
|
) |
| |
|
inline |
◆ ConsoleTextStylePolicyFor
template<class T , class TRecord >
concept sl::log::ConsoleTextStylePolicyFor |
Initial value:=
Record<TRecord> &&
std::is_invocable_r_v<ConsoleTextStyle, T, const TRecord&>
Concept which checks for validity of given text style policy.
◆ defaultConsoleTextStyle
A constant object used for resetting the style back to default.
- Version
- since alpha-0.6