mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
Updated clang format to google style
This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/details/registry.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
#include <spdlog/logger.h>
|
||||
#include <spdlog/version.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@@ -30,9 +30,8 @@ using default_factory = synchronous_factory;
|
||||
//
|
||||
// Example:
|
||||
// spdlog::create<daily_file_sink_st>("logger_name", "dailylog_filename", 11, 59);
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...sink_args)
|
||||
{
|
||||
template <typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...sink_args) {
|
||||
return default_factory::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
|
||||
}
|
||||
|
||||
@@ -72,9 +71,8 @@ SPDLOG_API void flush_on(level level);
|
||||
|
||||
// Start/Restart a periodic flusher thread
|
||||
// Warning: Use only if all your loggers are thread safe!
|
||||
template<typename Rep, typename Period>
|
||||
inline void flush_every(std::chrono::duration<Rep, Period> interval)
|
||||
{
|
||||
template <typename Rep, typename Period>
|
||||
inline void flush_every(std::chrono::duration<Rep, Period> interval) {
|
||||
details::registry::instance().flush_every(interval);
|
||||
}
|
||||
|
||||
@@ -131,164 +129,112 @@ SPDLOG_API void set_default_logger(std::shared_ptr<spdlog::logger> default_logge
|
||||
// spdlog::apply_logger_env_levels(mylogger);
|
||||
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, level lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... 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(level lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... 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, level lvl, S fmt, Args &&...args)
|
||||
{
|
||||
template <typename S, typename = is_convertible_to_sv<S>, typename... 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(level lvl, S fmt, Args &&...args)
|
||||
{
|
||||
template <typename S, typename = is_convertible_to_sv<S>, typename... Args>
|
||||
inline void log(level lvl, S fmt, Args &&...args) {
|
||||
default_logger_raw()->log(lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
#ifdef SPDLOG_SOURCE_LOCATION
|
||||
template<typename... Args>
|
||||
inline void trace(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void trace(loc_with_fmt fmt, 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)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void debug(loc_with_fmt fmt, 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)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void info(loc_with_fmt fmt, 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)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void warn(loc_with_fmt fmt, 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)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void error(loc_with_fmt fmt, 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)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void critical(loc_with_fmt fmt, 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, level::trace, msg);
|
||||
}
|
||||
inline void trace(string_view_t msg, source_loc loc = source_loc::current()) { log(loc, level::trace, msg); }
|
||||
|
||||
inline void debug(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, level::debug, msg);
|
||||
}
|
||||
inline void debug(string_view_t msg, source_loc loc = source_loc::current()) { log(loc, level::debug, msg); }
|
||||
|
||||
inline void info(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, level::info, msg);
|
||||
}
|
||||
inline void info(string_view_t msg, source_loc loc = source_loc::current()) { log(loc, level::info, msg); }
|
||||
|
||||
inline void warn(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, spdlog::level::warn, msg);
|
||||
}
|
||||
inline void warn(string_view_t msg, source_loc loc = source_loc::current()) { log(loc, spdlog::level::warn, msg); }
|
||||
|
||||
inline void error(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, level::err, msg);
|
||||
}
|
||||
inline void error(string_view_t msg, source_loc loc = source_loc::current()) { log(loc, level::err, msg); }
|
||||
|
||||
inline void critical(string_view_t msg, source_loc loc = source_loc::current())
|
||||
{
|
||||
log(loc, level::critical, msg);
|
||||
}
|
||||
inline void critical(string_view_t msg, source_loc loc = source_loc::current()) { log(loc, level::critical, msg); }
|
||||
#else
|
||||
template<typename... Args>
|
||||
inline void trace(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void trace(format_string_t<Args...> fmt, Args &&...args) {
|
||||
log(level::trace, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void debug(format_string_t<Args...> fmt, Args &&...args) {
|
||||
log(level::debug, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void info(format_string_t<Args...> fmt, Args &&...args) {
|
||||
log(level::info, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void warn(format_string_t<Args...> fmt, Args &&...args) {
|
||||
log(level::warn, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void error(format_string_t<Args...> fmt, Args &&...args) {
|
||||
log(level::err, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
template <typename... Args>
|
||||
inline void critical(format_string_t<Args...> fmt, 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(level::trace, msg);
|
||||
}
|
||||
inline void trace(string_view_t msg) { log(level::trace, msg); }
|
||||
|
||||
inline void debug(string_view_t msg)
|
||||
{
|
||||
log(level::debug, msg);
|
||||
}
|
||||
inline void debug(string_view_t msg) { log(level::debug, msg); }
|
||||
|
||||
inline void info(string_view_t msg)
|
||||
{
|
||||
log(level::info, msg);
|
||||
}
|
||||
inline void info(string_view_t msg) { log(level::info, msg); }
|
||||
|
||||
inline void warn(string_view_t msg)
|
||||
{
|
||||
log(level::warn, msg);
|
||||
}
|
||||
inline void warn(string_view_t msg) { log(level::warn, msg); }
|
||||
|
||||
inline void error(string_view_t msg)
|
||||
{
|
||||
log(level::err, msg);
|
||||
}
|
||||
inline void error(string_view_t msg) { log(level::err, msg); }
|
||||
|
||||
inline void critical(string_view_t msg)
|
||||
{
|
||||
log(level::critical, msg);
|
||||
}
|
||||
inline void critical(string_view_t msg) { log(level::critical, msg); }
|
||||
#endif
|
||||
|
||||
} // namespace spdlog
|
||||
@@ -307,58 +253,58 @@ inline void critical(string_view_t msg)
|
||||
//
|
||||
|
||||
#ifdef SPDLOG_SOURCE_LOCATION
|
||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
||||
#define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
||||
(logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{}, level, __VA_ARGS__)
|
||||
#define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{}, level, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
||||
# 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__)
|
||||
#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
|
||||
# define SPDLOG_TRACE(...) (void)0
|
||||
#define SPDLOG_LOGGER_TRACE(logger, ...) (void)0
|
||||
#define SPDLOG_TRACE(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG
|
||||
# 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__)
|
||||
#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
|
||||
# define SPDLOG_DEBUG(...) (void)0
|
||||
#define SPDLOG_LOGGER_DEBUG(logger, ...) (void)0
|
||||
#define SPDLOG_DEBUG(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO
|
||||
# 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__)
|
||||
#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
|
||||
# define SPDLOG_INFO(...) (void)0
|
||||
#define SPDLOG_LOGGER_INFO(logger, ...) (void)0
|
||||
#define SPDLOG_INFO(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_WARN
|
||||
# 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__)
|
||||
#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
|
||||
# define SPDLOG_WARN(...) (void)0
|
||||
#define SPDLOG_LOGGER_WARN(logger, ...) (void)0
|
||||
#define SPDLOG_WARN(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_ERROR
|
||||
# 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__)
|
||||
#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
|
||||
# define SPDLOG_ERROR(...) (void)0
|
||||
#define SPDLOG_LOGGER_ERROR(logger, ...) (void)0
|
||||
#define SPDLOG_ERROR(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_CRITICAL
|
||||
# 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__)
|
||||
#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
|
||||
# define SPDLOG_CRITICAL(...) (void)0
|
||||
#define SPDLOG_LOGGER_CRITICAL(logger, ...) (void)0
|
||||
#define SPDLOG_CRITICAL(...) (void)0
|
||||
#endif
|
||||
|
||||
#endif // SPDLOG_H
|
||||
|
Reference in New Issue
Block a user