diff --git a/include/spdlog/details/registry-inl.h b/include/spdlog/details/registry-inl.h index a60faabc..6451957a 100644 --- a/include/spdlog/details/registry-inl.h +++ b/include/spdlog/details/registry-inl.h @@ -195,14 +195,14 @@ SPDLOG_INLINE void registry::flush_every(std::chrono::seconds interval) periodic_flusher_ = details::make_unique(clbk, interval); } -SPDLOG_INLINE void registry::set_error_handler(void (*handler)(const std::string &msg)) +SPDLOG_INLINE void registry::set_error_handler(err_handler handler) { std::lock_guard lock(logger_map_mutex_); for (auto &l : loggers_) { l.second->set_error_handler(handler); } - err_handler_ = handler; + err_handler_ = std::move(handler); } SPDLOG_INLINE void registry::apply_all(const std::function)> &fun) diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index b069c3f5..c626104f 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -63,7 +63,7 @@ public: void flush_every(std::chrono::seconds interval); - void set_error_handler(void (*handler)(const std::string &msg)); + void set_error_handler(err_handler handler); void apply_all(const std::function)> &fun); @@ -99,7 +99,7 @@ private: std::unique_ptr formatter_; spdlog::level::level_enum global_log_level_ = level::info; level::level_enum flush_level_ = level::off; - void (*err_handler_)(const std::string &msg) = nullptr; + err_handler err_handler_; std::shared_ptr tp_; std::unique_ptr periodic_flusher_; std::shared_ptr default_logger_;