Moved should_flush_ to header

This commit is contained in:
gabime 2025-01-06 07:45:08 +02:00
parent 3d83e402ca
commit 04004e57c2
2 changed files with 6 additions and 8 deletions

View File

@ -121,6 +121,11 @@ public:
// return true if logging is enabled for the given level.
[[nodiscard]] bool should_log(level msg_level) const { return msg_level >= level_.load(std::memory_order_relaxed); }
// return true if the given message should be flushed
[[nodiscard]] bool should_flush(const details::log_msg &msg) const {
return (msg.log_level >= flush_level_.load(std::memory_order_relaxed)) && (msg.log_level != level::off);
}
// set the level of logging
void set_level(level level);
@ -193,12 +198,11 @@ private:
}
}
if (should_flush_(msg)) {
if (should_flush(msg)) {
flush_();
}
}
void flush_();
[[nodiscard]] bool should_flush_(const details::log_msg &msg) const;
};
} // namespace spdlog

View File

@ -81,10 +81,4 @@ void logger::flush_() {
}
}
}
bool logger::should_flush_(const details::log_msg &msg) const {
const auto flush_level = flush_level_.load(std::memory_order_relaxed);
return (msg.log_level >= flush_level) && (msg.log_level != level::off);
}
} // namespace spdlog