From e4adba854cca1bcf8c3b2f286af28f8fcb96feb1 Mon Sep 17 00:00:00 2001 From: xaqq Date: Mon, 10 Nov 2014 18:39:55 +0100 Subject: [PATCH] Add NOTICE, ALERT and EMERG log level. This commit introduces 3 new log level. Thoses are: + NOTICE, which is a bit worse that INFO, but still not a warn. + ALERT, for case worse that critical. + EMERG, application is unusable. With those 3 log levels, spdlog now has all log level accepted by the syslog() system call. --- include/spdlog/common.h | 6 +++++- include/spdlog/details/logger_impl.h | 18 ++++++++++++++++++ include/spdlog/logger.h | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 521ded2f..bbfe7748 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -49,14 +49,18 @@ typedef enum TRACE, DEBUG, INFO, + NOTICE, WARN, ERR, CRITICAL, + ALERT, + EMERG, ALWAYS, OFF } level_enum; -static const char* level_names[] { "trace", "debug", "info", "warning", "error", "critical", "", ""}; +static const char* level_names[] { "trace", "debug", "info", "notice", "warning", "error", "critical", + "alert", "emerg", "", ""}; inline const char* to_str(spdlog::level::level_enum l) { return level_names[l]; diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index 1e8b020d..25fb121b 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -101,6 +101,12 @@ inline spdlog::details::line_logger spdlog::logger::info(const Args&... args) return log(level::INFO, args...); } +template +inline spdlog::details::line_logger spdlog::logger::notice(const Args&... args) +{ + return log(level::NOTICE, args...); +} + template inline spdlog::details::line_logger spdlog::logger::warn(const Args&... args) { @@ -119,6 +125,18 @@ inline spdlog::details::line_logger spdlog::logger::critical(const Args&... args return log(level::CRITICAL, args...); } +template +inline spdlog::details::line_logger spdlog::logger::alert(const Args&... args) +{ + return log(level::ALERT, args...); +} + +template +inline spdlog::details::line_logger spdlog::logger::emerg(const Args&... args) +{ + return log(level::EMERG, args...); +} + inline const std::string& spdlog::logger::name() const { return _name; diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 522f0eb7..1fe8dc54 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -75,9 +75,12 @@ public: template details::line_logger trace(const Args&... args); template details::line_logger debug(const Args&... args); template details::line_logger info(const Args&... args); + template details::line_logger notice(const Args&... args); template details::line_logger warn(const Args&... args); template details::line_logger error(const Args&... args); template details::line_logger critical(const Args&... args); + template details::line_logger alert(const Args&... args); + template details::line_logger emerg(const Args&... args); private: