From bfbb4e40500344c7945c4a70ef45deed255d6f63 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 5 Apr 2019 23:40:27 +0300 Subject: [PATCH] some err handler cleanup --- include/spdlog/logger.h | 5 +++-- src/logger.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index c27ddcfe..6b6c736b 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -32,6 +32,7 @@ namespace spdlog { class logger { public: + using err_handler = void (*)(const std::string &msg); template logger(std::string name, It begin, It end) : name_(std::move(name)) @@ -318,7 +319,7 @@ public: std::vector &sinks(); // error handler - void set_error_handler(void (*handler)(const std::string& msg)); + void set_error_handler(err_handler); // create new logger with same sinks and configuration. virtual std::shared_ptr clone(std::string logger_name); @@ -340,7 +341,7 @@ public: std::vector sinks_; spdlog::level_t level_{spdlog::logger::default_level()}; spdlog::level_t flush_level_{level::off}; - void (*custom_err_handler_)(const std::string &msg) {nullptr}; + err_handler custom_err_handler_{nullptr}; }; diff --git a/src/logger.cpp b/src/logger.cpp index 32396524..4ef4cc88 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -113,7 +113,7 @@ SPDLOG_INLINE std::vector &spdlog::logger::sinks() } // error handler -SPDLOG_INLINE void spdlog::logger::set_error_handler(void (*handler)(const std::string &msg)) +SPDLOG_INLINE void spdlog::logger::set_error_handler(err_handler handler) { custom_err_handler_ = handler; }