Sink class for directly logging onto std::cout.
More...
#include <ConsoleSink.hpp>
|
template<class TData > |
void | writeToStream (TData &&data) |
| Writes directly to the internal stream. More...
|
|
template<Record TRecord>
class sl::log::ConsoleSink< TRecord >
Sink class for directly logging onto std::cout.
- Template Parameters
-
This Sink class directly uses a std::cout object for printing each recorded message. Users may register ConsoleTextStyles which will then colorized or printed the messages in a specific style.
- Version
- since alpha-0.6
- Examples
- ColorizedConsoleLogging/main.cpp, CustomRecordType/main.cpp, and CustomizeBaseRecord/main.cpp.
◆ Filter_t
◆ FlushPolicy_t
◆ Formatter_t
◆ Projections_t
◆ Record_t
◆ TextStylePolicy_t
◆ ConsoleSink() [1/3]
◆ ~ConsoleSink()
Default destructor.
Destructor does not perform any actions on the internal stream objects, due to it's potential dangling state. Derived classes must handle closing and flushing themselves.
◆ ConsoleSink() [2/3]
Deleted copy constructor.
◆ ConsoleSink() [3/3]
Deleted move constructor.
◆ defaultFilter()
template<Record TRecord>
|
inlinestaticconstexprprotectednoexceptinherited |
◆ defaultFlushPolicy()
template<Record TRecord>
|
inlinestaticconstexprprotectednoexceptinherited |
◆ defaultFormatter()
template<Record TRecord>
|
inlinestaticconstexprprotectednoexceptinherited |
◆ defaultTextStylePolicy()
template<Record TRecord>
|
inlinestaticconstexprprotected |
Constructs the default TextStylePolicy.
- Returns
- a invokable object
◆ flush()
Flushes all pending output of the internal stream.
◆ isEnabled()
template<Record TRecord>
|
inlinefinaloverridevirtualnoexceptinherited |
◆ log()
template<Record TRecord>
|
inlinefinaloverridevirtualinherited |
Handles the given Record object.
Before the Record gets passed to the actual destination, it will be checked if the Sink object is enabled and if the Record should be filtered. If these checks are passed, the abstract writeMessage function will be invoked with the finally formatted message string.
- Parameters
-
Implements sl::log::ISink< TRecord >.
◆ operator=() [1/2]
Deleted move assign operator.
◆ operator=() [2/2]
Deleted copy assign operator.
◆ removeFilter()
Replaces the active filter with the default one.
◆ removeFlushPolicy()
Replaces the current Flush-Policy with the default one.
The default Flush-Policy flushes after each handled Record.
◆ removeFormatter()
Replaces the active formatter with the default one.
◆ removeTextStylePolicy()
Replaces the current ConsoleTextStylePolicy with the default one.
◆ setEnabled()
template<Record TRecord>
|
inlinefinaloverridevirtualnoexceptinherited |
Enables or disables the Sink object.
Disabled Sinks will not handle any incoming Record s
- Parameters
-
enable | True will enable the Sink object. |
Implements sl::log::ISink< TRecord >.
◆ setFilter()
template<Record TRecord>
template<RecordFilterFor< Record_t > TFilter>
Sets the active filter.
It's the filters job to decide, which Record will be printed (filter returns true) and which will be skipped (filter returns false). Therefore a filter must be an invokable of the following signature:
concept Record
Concept which all the necessary concepts for Record types.
Definition: Record.hpp:204
- Template Parameters
-
TFilter | Type of the passed filter (automatically deduced) |
- Parameters
-
filter | An invokable filter object |
- Examples
- FileLogging/main.cpp.
◆ setFlushPolicy()
template<Record TRecord>
template<FlushPolicyFor< Record_t > TPolicy>
Sets the active Flush-Policy.
- Template Parameters
-
TPolicy | Type of the passed Flush-Policy (automatically deduced) |
- Parameters
-
policy | The new Flush-Policy object |
◆ setFormatter()
template<Record TRecord>
template<RecordFormatterFor< Record_t > TFormatter>
Sets the active formatter.
It's the formatters job to extract the necessary information from Records and built the final message string.
A custom formatter should use the following signature:
- Template Parameters
-
TFormatter | Type of the passed formatter (automatically deduced) |
- Parameters
-
formatter | An invokable formatter object |
◆ setTextStylePolicy()
template<Record TRecord>
template<ConsoleTextStylePolicyFor< Record_t > TStylePolicy>
Sets the active ConsoleTextStylePolicy.
- Template Parameters
-
TStylePolicy | Type of the passed ConsoleTextStylePolicy (automatically deduced) |
- Parameters
-
policy | The new ConsoleTextStylePolicy object |
◆ writeToStream()
template<Record TRecord>
template<class TData >
Writes directly to the internal stream.
- Template Parameters
-
TData | Type of data (automatically deduced) |
- Parameters
-
data | Data which will be written to the stream. |
This functions writes directly to the stream object. No filter or formatter will be involved and stream will be flush afterwards. This might be useful for writing custom header or footer data to the stream.
The documentation for this class was generated from the following file: