mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 18:39:03 +08:00
log levels now lowercase
This commit is contained in:
@@ -54,16 +54,16 @@ namespace level
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
TRACE = 0,
|
||||
DEBUG = 1,
|
||||
INFO = 2,
|
||||
NOTICE = 3,
|
||||
WARN = 4,
|
||||
ERR = 5,
|
||||
CRITICAL = 6,
|
||||
ALERT = 7,
|
||||
EMERG = 8,
|
||||
OFF = 9
|
||||
trace = 0,
|
||||
debug = 1,
|
||||
info = 2,
|
||||
notice = 3,
|
||||
warn = 4,
|
||||
err = 5,
|
||||
critical = 6,
|
||||
alert = 7,
|
||||
emerg = 8,
|
||||
off = 9
|
||||
} level_enum;
|
||||
|
||||
static const char* level_names[] { "trace", "debug", "info", "notice", "warning", "error", "critical", "alert", "emerg", "off"};
|
||||
|
@@ -63,7 +63,7 @@ inline void spdlog::async_logger::_set_pattern(const std::string& pattern)
|
||||
|
||||
inline void spdlog::async_logger::_stop()
|
||||
{
|
||||
set_level(level::OFF);
|
||||
set_level(level::off);
|
||||
}
|
||||
|
||||
inline void spdlog::async_logger::_log_msg(details::log_msg& msg)
|
||||
|
@@ -80,7 +80,7 @@ struct log_msg
|
||||
|
||||
void clear()
|
||||
{
|
||||
level = level::OFF;
|
||||
level = level::off;
|
||||
raw.clear();
|
||||
formatted.clear();
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ inline spdlog::logger::logger(const std::string& logger_name, const It& begin, c
|
||||
{
|
||||
|
||||
// no support under vs2013 for member initialization for std::atomic
|
||||
_level = level::INFO;
|
||||
_level = level::info;
|
||||
}
|
||||
|
||||
// ctor with sinks as init list
|
||||
@@ -92,55 +92,55 @@ inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::trace(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::TRACE, fmt, args...);
|
||||
return _log_if_enabled(level::trace, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::debug(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::DEBUG, fmt, args...);
|
||||
return _log_if_enabled(level::debug, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::info(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::INFO, fmt, args...);
|
||||
return _log_if_enabled(level::info, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::notice(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::NOTICE, fmt, args...);
|
||||
return _log_if_enabled(level::notice, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::warn(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::WARN, fmt, args...);
|
||||
return _log_if_enabled(level::warn, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::error(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::ERR, fmt, args...);
|
||||
return _log_if_enabled(level::err, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::critical(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::CRITICAL, fmt, args...);
|
||||
return _log_if_enabled(level::critical, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::alert(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::ALERT, fmt, args...);
|
||||
return _log_if_enabled(level::alert, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline spdlog::details::line_logger spdlog::logger::emerg(const char* fmt, const Args&... args)
|
||||
{
|
||||
return _log_if_enabled(level::EMERG, fmt, args...);
|
||||
return _log_if_enabled(level::emerg, fmt, args...);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,48 +152,48 @@ inline spdlog::details::line_logger spdlog::logger::emerg(const char* fmt, const
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::trace()
|
||||
{
|
||||
return _log_if_enabled(level::TRACE);
|
||||
return _log_if_enabled(level::trace);
|
||||
}
|
||||
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::debug()
|
||||
{
|
||||
return _log_if_enabled(level::DEBUG);
|
||||
return _log_if_enabled(level::debug);
|
||||
}
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::info()
|
||||
{
|
||||
return _log_if_enabled(level::INFO);
|
||||
return _log_if_enabled(level::info);
|
||||
}
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::notice()
|
||||
{
|
||||
return _log_if_enabled(level::NOTICE);
|
||||
return _log_if_enabled(level::notice);
|
||||
}
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::warn()
|
||||
{
|
||||
return _log_if_enabled(level::WARN);
|
||||
return _log_if_enabled(level::warn);
|
||||
}
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::error()
|
||||
{
|
||||
return _log_if_enabled(level::ERR);
|
||||
return _log_if_enabled(level::err);
|
||||
}
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::critical()
|
||||
{
|
||||
return _log_if_enabled(level::CRITICAL);
|
||||
return _log_if_enabled(level::critical);
|
||||
}
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::alert()
|
||||
{
|
||||
return _log_if_enabled(level::ALERT);
|
||||
return _log_if_enabled(level::alert);
|
||||
}
|
||||
|
||||
inline spdlog::details::line_logger spdlog::logger::emerg()
|
||||
{
|
||||
return _log_if_enabled(level::EMERG);
|
||||
return _log_if_enabled(level::emerg);
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ inline void spdlog::logger::_set_formatter(formatter_ptr msg_formatter)
|
||||
|
||||
inline void spdlog::logger::_stop()
|
||||
{
|
||||
set_level(level::OFF);
|
||||
set_level(level::off);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -130,7 +130,7 @@ public:
|
||||
void stop_all()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
_level = level::OFF;
|
||||
_level = level::off;
|
||||
for (auto& l : _loggers)
|
||||
l.second->stop();
|
||||
}
|
||||
@@ -149,7 +149,7 @@ private:
|
||||
std::mutex _mutex;
|
||||
std::unordered_map <std::string, std::shared_ptr<logger>> _loggers;
|
||||
formatter_ptr _formatter;
|
||||
level::level_enum _level = level::INFO;
|
||||
level::level_enum _level = level::info;
|
||||
bool _async_mode = false;
|
||||
size_t _async_q_size = 0;
|
||||
};
|
||||
|
@@ -50,16 +50,16 @@ public:
|
||||
syslog_sink(const std::string& ident = "", int syslog_option=0, int syslog_facility=LOG_USER):
|
||||
_ident(ident)
|
||||
{
|
||||
_priorities[static_cast<int>(level::TRACE)] = LOG_DEBUG;
|
||||
_priorities[static_cast<int>(level::DEBUG)] = LOG_DEBUG;
|
||||
_priorities[static_cast<int>(level::INFO)] = LOG_INFO;
|
||||
_priorities[static_cast<int>(level::NOTICE)] = LOG_NOTICE;
|
||||
_priorities[static_cast<int>(level::WARN)] = LOG_WARNING;
|
||||
_priorities[static_cast<int>(level::ERR)] = LOG_ERR;
|
||||
_priorities[static_cast<int>(level::CRITICAL)] = LOG_CRIT;
|
||||
_priorities[static_cast<int>(level::ALERT)] = LOG_ALERT;
|
||||
_priorities[static_cast<int>(level::EMERG)] = LOG_EMERG;
|
||||
_priorities[static_cast<int>(level::OFF)] = LOG_INFO;
|
||||
_priorities[static_cast<int>(level::trace)] = LOG_DEBUG;
|
||||
_priorities[static_cast<int>(level::debug)] = LOG_DEBUG;
|
||||
_priorities[static_cast<int>(level::info)] = LOG_INFO;
|
||||
_priorities[static_cast<int>(level::notice)] = LOG_NOTICE;
|
||||
_priorities[static_cast<int>(level::warn)] = LOG_WARNING;
|
||||
_priorities[static_cast<int>(level::err)] = LOG_ERR;
|
||||
_priorities[static_cast<int>(level::critical)] = LOG_CRIT;
|
||||
_priorities[static_cast<int>(level::alert)] = LOG_ALERT;
|
||||
_priorities[static_cast<int>(level::emerg)] = LOG_EMERG;
|
||||
_priorities[static_cast<int>(level::off)] = LOG_INFO;
|
||||
|
||||
//set ident to be program name if empty
|
||||
::openlog(_ident.empty()? nullptr:_ident.c_str(), syslog_option, syslog_facility);
|
||||
|
Reference in New Issue
Block a user