File indexing completed on 2025-01-18 10:12:44
0001
0002
0003
0004 #pragma once
0005
0006 #ifndef SPDLOG_HEADER_ONLY
0007 # include <spdlog/spdlog.h>
0008 #endif
0009
0010 #include <spdlog/common.h>
0011 #include <spdlog/pattern_formatter.h>
0012
0013 namespace spdlog {
0014
0015 SPDLOG_INLINE void initialize_logger(std::shared_ptr<logger> logger)
0016 {
0017 details::registry::instance().initialize_logger(std::move(logger));
0018 }
0019
0020 SPDLOG_INLINE std::shared_ptr<logger> get(const std::string &name)
0021 {
0022 return details::registry::instance().get(name);
0023 }
0024
0025 SPDLOG_INLINE void set_formatter(std::unique_ptr<spdlog::formatter> formatter)
0026 {
0027 details::registry::instance().set_formatter(std::move(formatter));
0028 }
0029
0030 SPDLOG_INLINE void set_pattern(std::string pattern, pattern_time_type time_type)
0031 {
0032 set_formatter(std::unique_ptr<spdlog::formatter>(new pattern_formatter(std::move(pattern), time_type)));
0033 }
0034
0035 SPDLOG_INLINE void enable_backtrace(size_t n_messages)
0036 {
0037 details::registry::instance().enable_backtrace(n_messages);
0038 }
0039
0040 SPDLOG_INLINE void disable_backtrace()
0041 {
0042 details::registry::instance().disable_backtrace();
0043 }
0044
0045 SPDLOG_INLINE void dump_backtrace()
0046 {
0047 default_logger_raw()->dump_backtrace();
0048 }
0049
0050 SPDLOG_INLINE level::level_enum get_level()
0051 {
0052 return default_logger_raw()->level();
0053 }
0054
0055 SPDLOG_INLINE bool should_log(level::level_enum log_level)
0056 {
0057 return default_logger_raw()->should_log(log_level);
0058 }
0059
0060 SPDLOG_INLINE void set_level(level::level_enum log_level)
0061 {
0062 details::registry::instance().set_level(log_level);
0063 }
0064
0065 SPDLOG_INLINE void flush_on(level::level_enum log_level)
0066 {
0067 details::registry::instance().flush_on(log_level);
0068 }
0069
0070 SPDLOG_INLINE void set_error_handler(void (*handler)(const std::string &msg))
0071 {
0072 details::registry::instance().set_error_handler(handler);
0073 }
0074
0075 SPDLOG_INLINE void register_logger(std::shared_ptr<logger> logger)
0076 {
0077 details::registry::instance().register_logger(std::move(logger));
0078 }
0079
0080 SPDLOG_INLINE void apply_all(const std::function<void(std::shared_ptr<logger>)> &fun)
0081 {
0082 details::registry::instance().apply_all(fun);
0083 }
0084
0085 SPDLOG_INLINE void drop(const std::string &name)
0086 {
0087 details::registry::instance().drop(name);
0088 }
0089
0090 SPDLOG_INLINE void drop_all()
0091 {
0092 details::registry::instance().drop_all();
0093 }
0094
0095 SPDLOG_INLINE void shutdown()
0096 {
0097 details::registry::instance().shutdown();
0098 }
0099
0100 SPDLOG_INLINE void set_automatic_registration(bool automatic_registration)
0101 {
0102 details::registry::instance().set_automatic_registration(automatic_registration);
0103 }
0104
0105 SPDLOG_INLINE std::shared_ptr<spdlog::logger> default_logger()
0106 {
0107 return details::registry::instance().default_logger();
0108 }
0109
0110 SPDLOG_INLINE spdlog::logger *default_logger_raw()
0111 {
0112 return details::registry::instance().get_default_raw();
0113 }
0114
0115 SPDLOG_INLINE void set_default_logger(std::shared_ptr<spdlog::logger> default_logger)
0116 {
0117 details::registry::instance().set_default_logger(std::move(default_logger));
0118 }
0119
0120 }