Function default_logger


#include <include/spdlog/spdlog.h>

SPDLOG_INLINE std::shared_ptr< spdlog::logger > default_logger()


API for using default logger (stdout_color_mt), e.g: spdlog::info("Message {}", 1);

The default logger object can be accessed using the spdlog::default_logger(): For example, to add another sink to it: spdlog::default_logger()->sinks().push_back(some_sink);

The default logger can replaced using spdlog::set_default_logger(new_logger). For example, to replace it with a file logger.

IMPORTANT: The default API is thread safe (for _mt loggers), but: set_default_logger() should not be used concurrently with the default API. e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.


Lines 110-113 in include/spdlog/spdlog-inl.h. Line 124 in include/spdlog/spdlog.h.

SPDLOG_INLINE std::shared_ptr<spdlog::logger> default_logger()
    return details::registry::instance().default_logger();

Add Discussion

Log in to comment