mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
Renamed spdlog::log_level to spdlog::level and added some level tests
This commit is contained in:
@@ -59,16 +59,16 @@ SPDLOG_API void set_formatter(std::unique_ptr<spdlog::formatter> formatter);
|
||||
SPDLOG_API void set_pattern(std::string pattern, pattern_time_type time_type = pattern_time_type::local);
|
||||
|
||||
// Get global logging level
|
||||
SPDLOG_API log_level get_level();
|
||||
SPDLOG_API level get_level();
|
||||
|
||||
// Set global logging level
|
||||
SPDLOG_API void set_level(log_level log_level);
|
||||
SPDLOG_API void set_level(level level);
|
||||
|
||||
// Determine whether the default logger should log messages with a certain level
|
||||
SPDLOG_API bool should_log(log_level lvl);
|
||||
SPDLOG_API bool should_log(level lvl);
|
||||
|
||||
// Set global flush level
|
||||
SPDLOG_API void flush_on(log_level log_level);
|
||||
SPDLOG_API void flush_on(level level);
|
||||
|
||||
// Start/Restart a periodic flusher thread
|
||||
// Warning: Use only if all your loggers are thread safe!
|
||||
@@ -132,25 +132,25 @@ SPDLOG_API void set_default_logger(std::shared_ptr<spdlog::logger> default_logge
|
||||
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, log_level lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
inline void log(source_loc source, level lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(log_level lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
inline void log(level lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename S, typename = is_convertible_to_sv<S>, typename... Args>
|
||||
inline void log(source_loc loc, log_level lvl, S fmt, Args &&...args)
|
||||
inline void log(source_loc loc, level lvl, S fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(loc, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename S, typename = is_convertible_to_sv<S>, typename... Args>
|
||||
inline void log(log_level lvl, S fmt, Args &&...args)
|
||||
inline void log(level lvl, S fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
@@ -159,135 +159,135 @@ inline void log(log_level lvl, S fmt, Args &&...args)
|
||||
template<typename... Args>
|
||||
inline void trace(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
log(fmt.loc, log_level::trace, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
log(fmt.loc, level::trace, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
log(fmt.loc, log_level::debug, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
log(fmt.loc, level::debug, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
log(fmt.loc, log_level::info, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
log(fmt.loc, level::info, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
log(fmt.loc, spdlog::log_level::warn, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
log(fmt.loc, spdlog::level::warn, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
log(fmt.loc, log_level::err, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
log(fmt.loc, level::err, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
log(fmt.loc, log_level::critical, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
log(fmt.loc, level::critical, fmt.fmt_string, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// log functions with no format string, just string
|
||||
inline void trace(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, log_level::trace, msg);
|
||||
log(loc, level::trace, msg);
|
||||
}
|
||||
|
||||
inline void debug(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, log_level::debug, msg);
|
||||
log(loc, level::debug, msg);
|
||||
}
|
||||
|
||||
inline void info(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, log_level::info, msg);
|
||||
log(loc, level::info, msg);
|
||||
}
|
||||
|
||||
inline void warn(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, spdlog::log_level::warn, msg);
|
||||
log(loc, spdlog::level::warn, msg);
|
||||
}
|
||||
|
||||
inline void error(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, log_level::err, msg);
|
||||
log(loc, level::err, msg);
|
||||
}
|
||||
|
||||
inline void critical(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, log_level::critical, msg);
|
||||
log(loc, level::critical, msg);
|
||||
}
|
||||
#else
|
||||
template<typename... Args>
|
||||
inline void trace(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(log_level::trace, fmt, std::forward<Args>(args)...);
|
||||
log(level::trace, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(log_level::debug, fmt, std::forward<Args>(args)...);
|
||||
log(level::debug, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(log_level::info, fmt, std::forward<Args>(args)...);
|
||||
log(level::info, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(log_level::warn, fmt, std::forward<Args>(args)...);
|
||||
log(level::warn, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(log_level::err, fmt, std::forward<Args>(args)...);
|
||||
log(level::err, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
log(log_level::critical, fmt, std::forward<Args>(args)...);
|
||||
log(level::critical, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// log functions with no format string, just string
|
||||
inline void trace(string_view_t msg)
|
||||
{
|
||||
log(log_level::trace, msg);
|
||||
log(level::trace, msg);
|
||||
}
|
||||
|
||||
inline void debug(string_view_t msg)
|
||||
{
|
||||
log(log_level::debug, msg);
|
||||
log(level::debug, msg);
|
||||
}
|
||||
|
||||
inline void info(string_view_t msg)
|
||||
{
|
||||
log(log_level::info, msg);
|
||||
log(level::info, msg);
|
||||
}
|
||||
|
||||
inline void warn(string_view_t msg)
|
||||
{
|
||||
log(log_level::warn, msg);
|
||||
log(level::warn, msg);
|
||||
}
|
||||
|
||||
inline void error(string_view_t msg)
|
||||
{
|
||||
log(log_level::err, msg);
|
||||
log(level::err, msg);
|
||||
}
|
||||
|
||||
inline void critical(string_view_t msg)
|
||||
{
|
||||
log(log_level::critical, msg);
|
||||
log(level::critical, msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -314,7 +314,7 @@ inline void critical(string_view_t msg)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
||||
# define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::log_level::trace, __VA_ARGS__)
|
||||
# define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__)
|
||||
# define SPDLOG_TRACE(...) SPDLOG_LOGGER_TRACE(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_TRACE(logger, ...) (void)0
|
||||
@@ -322,7 +322,7 @@ inline void critical(string_view_t msg)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG
|
||||
# define SPDLOG_LOGGER_DEBUG(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::log_level::debug, __VA_ARGS__)
|
||||
# define SPDLOG_LOGGER_DEBUG(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::debug, __VA_ARGS__)
|
||||
# define SPDLOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_DEBUG(logger, ...) (void)0
|
||||
@@ -330,7 +330,7 @@ inline void critical(string_view_t msg)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO
|
||||
# define SPDLOG_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::log_level::info, __VA_ARGS__)
|
||||
# define SPDLOG_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::info, __VA_ARGS__)
|
||||
# define SPDLOG_INFO(...) SPDLOG_LOGGER_INFO(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_INFO(logger, ...) (void)0
|
||||
@@ -338,7 +338,7 @@ inline void critical(string_view_t msg)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_WARN
|
||||
# define SPDLOG_LOGGER_WARN(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::log_level::warn, __VA_ARGS__)
|
||||
# define SPDLOG_LOGGER_WARN(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::warn, __VA_ARGS__)
|
||||
# define SPDLOG_WARN(...) SPDLOG_LOGGER_WARN(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_WARN(logger, ...) (void)0
|
||||
@@ -346,7 +346,7 @@ inline void critical(string_view_t msg)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_ERROR
|
||||
# define SPDLOG_LOGGER_ERROR(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::log_level::err, __VA_ARGS__)
|
||||
# define SPDLOG_LOGGER_ERROR(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::err, __VA_ARGS__)
|
||||
# define SPDLOG_ERROR(...) SPDLOG_LOGGER_ERROR(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_ERROR(logger, ...) (void)0
|
||||
@@ -354,7 +354,7 @@ inline void critical(string_view_t msg)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_CRITICAL
|
||||
# define SPDLOG_LOGGER_CRITICAL(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::log_level::critical, __VA_ARGS__)
|
||||
# define SPDLOG_LOGGER_CRITICAL(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::critical, __VA_ARGS__)
|
||||
# define SPDLOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_CRITICAL(logger, ...) (void)0
|
||||
|
Reference in New Issue
Block a user