2
0
mirror of https://github.com/gabime/spdlog.git synced 2026-01-19 04:52:09 +00:00

Add const qualifier to get_time_ and filter_ member functions (#3515)

This commit is contained in:
Kağan Can Şit
2026-01-11 00:33:43 +03:00
committed by GitHub
parent d299603e45
commit 1774e70082
3 changed files with 4 additions and 4 deletions

View File

@@ -1011,7 +1011,7 @@ SPDLOG_INLINE void pattern_formatter::set_pattern(std::string pattern) {
SPDLOG_INLINE void pattern_formatter::need_localtime(bool need) { need_localtime_ = need; }
SPDLOG_INLINE std::tm pattern_formatter::get_time_(const details::log_msg &msg) {
SPDLOG_INLINE std::tm pattern_formatter::get_time_(const details::log_msg &msg) const {
if (pattern_time_type_ == pattern_time_type::local) {
return details::os::localtime(log_clock::to_time_t(msg.time));
}

View File

@@ -99,7 +99,7 @@ private:
std::vector<std::unique_ptr<details::flag_formatter>> formatters_;
custom_flags custom_handlers_;
std::tm get_time_(const details::log_msg &msg);
std::tm get_time_(const details::log_msg &msg) const;
template <typename Padder>
void handle_flag_(char flag, details::padding_info padding);

View File

@@ -78,8 +78,8 @@ protected:
}
// return whether the log msg should be displayed (true) or skipped (false)
bool filter_(const details::log_msg &msg) {
auto filter_duration = msg.time - last_msg_time_;
bool filter_(const details::log_msg &msg) const {
const auto filter_duration = msg.time - last_msg_time_;
return (filter_duration > max_skip_duration_) || (msg.payload != last_msg_payload_);
}
};