mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
Inlined sink_it_
This commit is contained in:
@@ -141,26 +141,6 @@ SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
|
||||
return cloned;
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void logger::sink_it_(const details::log_msg &msg)
|
||||
{
|
||||
for (auto &sink : sinks_)
|
||||
{
|
||||
if (sink->should_log(msg.level))
|
||||
{
|
||||
SPDLOG_TRY
|
||||
{
|
||||
sink->log(msg);
|
||||
}
|
||||
SPDLOG_LOGGER_CATCH(msg.source)
|
||||
}
|
||||
}
|
||||
|
||||
if (should_flush_(msg))
|
||||
{
|
||||
flush_();
|
||||
}
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void logger::flush_()
|
||||
{
|
||||
for (auto &sink : sinks_)
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/details/log_msg.h>
|
||||
#include <spdlog/sinks/sink.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -263,7 +264,25 @@ protected:
|
||||
}
|
||||
|
||||
// log the given message (if the given log level is high enough)
|
||||
virtual void sink_it_(const details::log_msg &msg);
|
||||
virtual void sink_it_(const details::log_msg &msg)
|
||||
{
|
||||
for (auto &sink : sinks_)
|
||||
{
|
||||
if (sink->should_log(msg.level))
|
||||
{
|
||||
SPDLOG_TRY
|
||||
{
|
||||
sink->log(msg);
|
||||
}
|
||||
SPDLOG_LOGGER_CATCH(msg.source)
|
||||
}
|
||||
}
|
||||
|
||||
if (should_flush_(msg))
|
||||
{
|
||||
flush_();
|
||||
}
|
||||
}
|
||||
virtual void flush_();
|
||||
bool should_flush_(const details::log_msg &msg);
|
||||
|
||||
|
Reference in New Issue
Block a user