Merge pull request #7 from xaqq/master

Add NOTICE, ALERT and EMERG log level - so spdlog log levels could be matched to syslog's
This commit is contained in:
Gabi Melman 2014-11-10 21:10:09 +02:00
commit 3569a76b4c
3 changed files with 26 additions and 1 deletions

View File

@ -49,14 +49,18 @@ typedef enum
TRACE, TRACE,
DEBUG, DEBUG,
INFO, INFO,
NOTICE,
WARN, WARN,
ERR, ERR,
CRITICAL, CRITICAL,
ALERT,
EMERG,
ALWAYS, ALWAYS,
OFF OFF
} level_enum; } 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) inline const char* to_str(spdlog::level::level_enum l)
{ {
return level_names[l]; return level_names[l];

View File

@ -101,6 +101,12 @@ inline spdlog::details::line_logger spdlog::logger::info(const Args&... args)
return log(level::INFO, args...); return log(level::INFO, args...);
} }
template <typename... Args>
inline spdlog::details::line_logger spdlog::logger::notice(const Args&... args)
{
return log(level::NOTICE, args...);
}
template <typename... Args> template <typename... Args>
inline spdlog::details::line_logger spdlog::logger::warn(const Args&... args) 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...); return log(level::CRITICAL, args...);
} }
template <typename... Args>
inline spdlog::details::line_logger spdlog::logger::alert(const Args&... args)
{
return log(level::ALERT, args...);
}
template <typename... Args>
inline spdlog::details::line_logger spdlog::logger::emerg(const Args&... args)
{
return log(level::EMERG, args...);
}
inline const std::string& spdlog::logger::name() const inline const std::string& spdlog::logger::name() const
{ {
return _name; return _name;

View File

@ -75,9 +75,12 @@ public:
template <typename... Args> details::line_logger trace(const Args&... args); template <typename... Args> details::line_logger trace(const Args&... args);
template <typename... Args> details::line_logger debug(const Args&... args); template <typename... Args> details::line_logger debug(const Args&... args);
template <typename... Args> details::line_logger info(const Args&... args); template <typename... Args> details::line_logger info(const Args&... args);
template <typename... Args> details::line_logger notice(const Args&... args);
template <typename... Args> details::line_logger warn(const Args&... args); template <typename... Args> details::line_logger warn(const Args&... args);
template <typename... Args> details::line_logger error(const Args&... args); template <typename... Args> details::line_logger error(const Args&... args);
template <typename... Args> details::line_logger critical(const Args&... args); template <typename... Args> details::line_logger critical(const Args&... args);
template <typename... Args> details::line_logger alert(const Args&... args);
template <typename... Args> details::line_logger emerg(const Args&... args);
private: private: