Function set_formatter

Synopsis

#include <include/spdlog/logger.h>

void set_formatter(std::unique_ptr< formatter > f)

Description

set formatting for the sinks in this logger. each sink will get a separate instance of the formatter object.

Source

Lines 84-99 in include/spdlog/logger-inl.h. Line 294 in include/spdlog/logger.h.

SPDLOG_INLINE void logger::set_formatter(std::unique_ptr<formatter> f)
{
    for (auto it = sinks_.begin(); it != sinks_.end(); ++it)
    {
        if (std::next(it) == sinks_.end())
        {
            // last element - we can be move it.
            (*it)->set_formatter(std::move(f));
            break; // to prevent clang-tidy warning
        }
        else
        {
            (*it)->set_formatter(f->clone());
        }
    }
}





Add Discussion

Log in to comment