diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index f58da3e2..9f32b667 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -24,14 +24,6 @@ public: : enable_formatting_{enable_formatting} , ident_{std::move(ident)} { - priorities_[static_cast(level::trace)] = LOG_DEBUG; - priorities_[static_cast(level::debug)] = LOG_DEBUG; - priorities_[static_cast(level::info)] = LOG_INFO; - priorities_[static_cast(level::warn)] = LOG_WARNING; - priorities_[static_cast(level::err)] = LOG_ERR; - priorities_[static_cast(level::critical)] = LOG_CRIT; - priorities_[static_cast(level::off)] = LOG_INFO; - // set ident to be program name if empty ::openlog(ident_.empty() ? nullptr : ident_.c_str(), syslog_option, syslog_facility); } @@ -67,7 +59,15 @@ protected: bool enable_formatting_ = false; private: - std::array priorities_; + std::array syslog_levels_ { + /* level::trace */ LOG_DEBUG, + /* level::debug */ LOG_DEBUG, + /* level::info */ LOG_INFO, + /* level::warn */ LOG_WARNING, + /* level::err */ LOG_ERR, + /* level::critical */ LOG_CRIT, + /* level::off */ LOG_INFO + }; // must store the ident because the man says openlog might use the pointer as // is and not a string copy const std::string ident_; @@ -77,7 +77,7 @@ private: // int syslog_prio_from_level(const details::log_msg &msg) const { - return priorities_[static_cast(msg.level)]; + return syslog_levels_.at(static_cast(msg.level)); } };