Refactored logger

This commit is contained in:
gabime
2019-10-18 16:10:30 +03:00
parent f3369677ef
commit fcc809f4f1
4 changed files with 28 additions and 45 deletions

View File

@@ -172,6 +172,18 @@ SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
}
// protected methods
SPDLOG_INLINE void logger::log_it_(const details::log_msg &log_msg)
{
if (should_log(log_msg.level))
{
sink_it_(log_msg);
}
if (tracer_.enabled())
{
tracer_.push_back(log_msg);
}
}
SPDLOG_INLINE void logger::sink_it_(const details::log_msg &msg)
{
for (auto &sink : sinks_)
@@ -207,7 +219,7 @@ SPDLOG_INLINE void logger::flush_()
SPDLOG_INLINE void logger::dump_backtrace_()
{
using details::log_msg;
if (tracer_)
if (tracer_.enabled())
{
sink_it_(log_msg{name(), level::info, "****************** Backtrace Start ******************"});
tracer_.foreach_pop([this](const log_msg &msg) { this->sink_it_(msg); });