Contents

class

SushiDSP::Logger

Formats log calls and hands each line at or above the minimum level to one sink.

Declared in
include/SushiDSP/log/Logger.hpp

Never call it from the audio thread; see include/SushiDSP/README.md.

Public member functions

Logger(std::shared_ptr< ILogSink > sink, LogLevel minimum_level) noexcept

Starts with a sink and a minimum level.

Parameters

sink

Must not be null.

Logger(const Logger &)=delete
Logger & operator=(const Logger &)=delete
Logger(Logger &&)=delete
Logger & operator=(Logger &&)=delete
~Logger()=default
std::shared_ptr< ILogSink > set_sink(std::shared_ptr< ILogSink > sink) noexcept

Replaces the sink; lines already handed to the old one stay with it.

Parameters

sink

Must not be null.

Returns

The sink that was in place.

void set_minimum_level(LogLevel level) noexcept

Sets the level below which lines are discarded at run time.

LogLevel minimum_level() const noexcept

Returns the level below which lines are discarded at run time.

bool is_enabled(LogLevel level) const noexcept

Reports whether a line of this level would reach the sink.

template <typename... Values>
void log(LogLevel level, const LogCategory &category, std::string_view format, const Values &... values) noexcept

Formats a message on the stack and writes it when its level is enabled.

Parameters

format

Positional {} markers only; see LogFormatter.hpp.

void write(const LogRecord &record) noexcept

Hands a formatted line to the sink whatever its level, and flushes after a Fatal.

void flush() noexcept

Returns once the sink has put every earlier line at its destination.