Inlined sink_it_

This commit is contained in:
gabime 2023-07-28 18:55:52 +03:00
parent 54d402e094
commit 7c054b6dba
2 changed files with 21 additions and 22 deletions

View File

@ -141,26 +141,6 @@ SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
return cloned; 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_() SPDLOG_INLINE void logger::flush_()
{ {
for (auto &sink : sinks_) for (auto &sink : sinks_)

View File

@ -16,6 +16,7 @@
#include <spdlog/common.h> #include <spdlog/common.h>
#include <spdlog/details/log_msg.h> #include <spdlog/details/log_msg.h>
#include <spdlog/sinks/sink.h>
#include <vector> #include <vector>
@ -263,7 +264,25 @@ protected:
} }
// log the given message (if the given log level is high enough) // 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_(); virtual void flush_();
bool should_flush_(const details::log_msg &msg); bool should_flush_(const details::log_msg &msg);