ModErn Text Analysis
META Enumerates Textual Applications
|
sink: A wrapper for a stream that a logger should write to. More...
#include <logger.h>
Public Types | |
using | formatter_func = std::function< std::string(const log_line &)> |
Convenience typedef for functions that format log lines. | |
using | filter_func = std::function< bool(const log_line &)> |
Convenience typedef for functions that filter log lines. | |
Public Member Functions | |
sink (std::ostream &stream, const filter_func &filter=[](const log_line &){return true;}, const formatter_func &formatter=&default_formatter) | |
Creates a new sink with the given formatting function and filtering function. More... | |
sink (std::ostream &stream, logger::severity_level sev, const formatter_func &formatter=&default_formatter) | |
Creates a new sink on the given stream, filtering out all results that are greater than or equal to the specified severity, using the provided formatting function. More... | |
void | write (const log_line &line) |
Writes the given log_line to the stream, formatting and filtering it as necessary. More... | |
Static Public Member Functions | |
static std::string | default_formatter (const log_line &line) |
The default formatting function. More... | |
Private Attributes | |
std::ostream & | stream_ |
Internal stream. | |
formatter_func | formatter_ |
The formatting functor. | |
filter_func | filter_ |
The filtering functor. | |
sink: A wrapper for a stream that a logger should write to.
|
inline |
Creates a new sink with the given formatting function and filtering function.
A filtering function should take a log_line by const-reference and determine if it should or should not be written to the stream. If a formatting function is not provided, use a sane default formatter.
stream | The stream this sink will write to |
formatter | The formatting function object to use to format the log_lines written to the stream |
filter | The filtering function used to determine if a given log_line should be written to the stream or not |
|
inline |
Creates a new sink on the given stream, filtering out all results that are greater than or equal to the specified severity, using the provided formatting function.
If no formatting function is provided, use a sane default.
stream | The stream this sink will write to |
sev | The severity level at or above which log lines will be kept |
formatter | The optional formatting function |
|
inline |
|
inlinestatic |