RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
ISink.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <memory>
6#include <string_view>
7
8namespace RST::Log {
9
10 struct LogMessage;
11 class Formatter;
12
14 class ISink {
15 public:
16 virtual ~ISink() = default;
17
19 virtual void write(const LogMessage& message) = 0;
20 virtual void flush() = 0;
21
23 virtual void setLevel(LogLevel level) noexcept = 0;
24 [[nodiscard]] virtual LogLevel getLevel() const noexcept = 0;
25 [[nodiscard]] virtual bool shouldLog(LogLevel level) const noexcept = 0;
26
28 virtual void setFormatter(std::shared_ptr<Formatter> formatter) = 0;
30 virtual void setPattern(std::string_view pattern) = 0;
31 };
32
33}
Turns a LogMessage into a line of text following a pattern.
Definition Formatter.hpp:17
Interface of the log destinations; derive from ASink to write a new sink.
Definition ISink.hpp:14
virtual void setLevel(LogLevel level) noexcept=0
Minimum level accepted by this sink.
virtual void write(const LogMessage &message)=0
Receives a message from a logger.
virtual ~ISink()=default
virtual LogLevel getLevel() const noexcept=0
virtual bool shouldLog(LogLevel level) const noexcept=0
virtual void setPattern(std::string_view pattern)=0
Formats the messages with pattern; see Formatter.
virtual void setFormatter(std::shared_ptr< Formatter > formatter)=0
Shares a Formatter between sinks.
virtual void flush()=0
Thread-safe logging: loggers, sinks, patterns and macros.
Definition Terminal.hpp:8
LogLevel
Severity of a message, from Trace to Fatal; Off disables logging.
Definition LogLevel.hpp:11
A log record as passed to the sinks.
Definition LogMessage.hpp:18