22 void setColorEnabled(
bool enabled)
noexcept { _colorEnabled.store(enabled, std::memory_order_relaxed); }
23 [[nodiscard]]
bool isColorEnabled() const noexcept {
return _colorEnabled.load(std::memory_order_relaxed); }
30 std::ostream& _target;
31 std::array<std::string, kLogLevelCount> _colors;
32 std::atomic<bool> _colorEnabled;
Base class for sinks: handles the level, the pattern and the locking.
Definition ASink.hpp:17
Writes colored lines to std::cout or another stream.
Definition ConsoleSink.hpp:16
void setColorEnabled(bool enabled) noexcept
Definition ConsoleSink.hpp:22
void log(const LogMessage &message) override
Writes one message; called with the sink mutex locked.
void flushSink() override
Flushes the output; called with the sink mutex locked.
bool isColorEnabled() const noexcept
Definition ConsoleSink.hpp:23
ConsoleSink(std::ostream &target=std::cout)
void setColor(LogLevel level, std::string_view colorCode)
Sets the ANSI color of level; see Terminal.
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