15 #ifdef SPDLOG_ENABLE_SYSLOG 37 return details::registry::instance().register_logger(logger);
42 return details::registry::instance().get(name);
47 details::registry::instance().drop(name);
53 return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, truncate);
58 return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, truncate);
64 return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, max_file_size, max_files);
69 return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, max_file_size, max_files);
75 return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, hour, minute);
80 return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, hour, minute);
113 auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_mt>();
119 auto sink = std::make_shared<spdlog::sinks::wincolor_stdout_sink_st>();
125 auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_mt>();
132 auto sink = std::make_shared<spdlog::sinks::wincolor_stderr_sink_st>();
136 #else //ansi terminal colors 140 auto sink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>();
146 auto sink = std::make_shared<spdlog::sinks::ansicolor_stdout_sink_st>();
152 auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>();
158 auto sink = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_st>();
163 #ifdef SPDLOG_ENABLE_SYSLOG 165 inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(
const std::string& logger_name,
const std::string& syslog_ident,
int syslog_option)
167 return create<spdlog::sinks::syslog_sink>(logger_name, syslog_ident, syslog_option);
172 inline std::shared_ptr<spdlog::logger> spdlog::android_logger(
const std::string& logger_name,
const std::string& tag)
174 return create<spdlog::sinks::android_sink>(logger_name, tag);
181 return details::registry::instance().create(logger_name, sink);
188 return details::registry::instance().create(logger_name, sinks);
192 template <
typename Sink,
typename...
Args>
195 sink_ptr sink = std::make_shared<Sink>(args...);
196 return details::registry::instance().create(logger_name, { sink });
201 inline std::shared_ptr<spdlog::logger>
spdlog::create(
const std::string& logger_name,
const It& sinks_begin,
const It& sinks_end)
203 return details::registry::instance().create(logger_name, sinks_begin, sinks_end);
207 inline std::shared_ptr<spdlog::logger>
spdlog::create_async(
const std::string& logger_name,
const sink_ptr& sink,
size_t queue_size,
const async_overflow_policy overflow_policy,
const std::function<
void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms,
const std::function<
void()>& worker_teardown_cb)
209 return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sink);
215 return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks);
219 inline std::shared_ptr<spdlog::logger>
spdlog::create_async(
const std::string& logger_name,
const It& sinks_begin,
const It& sinks_end,
size_t queue_size,
const async_overflow_policy overflow_policy,
const std::function<
void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms,
const std::function<
void()>& worker_teardown_cb)
221 return details::registry::instance().create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, sinks_begin, sinks_end);
226 details::registry::instance().formatter(f);
231 return details::registry::instance().set_pattern(format_string);
236 return details::registry::instance().set_level(log_level);
241 return details::registry::instance().set_error_handler(handler);
245 inline void spdlog::set_async_mode(
size_t queue_size,
const async_overflow_policy overflow_policy,
const std::function<
void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms,
const std::function<
void()>& worker_teardown_cb)
247 details::registry::instance().set_async_mode(queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb);
252 details::registry::instance().set_sync_mode();
257 details::registry::instance().apply_all(fun);
262 details::registry::instance().drop_all();
void set_async_mode(size_t queue_size, const async_overflow_policy overflow_policy=async_overflow_policy::block_retry, const std::function< void()> &worker_warmup_cb=nullptr, const std::chrono::milliseconds &flush_interval_ms=std::chrono::milliseconds::zero(), const std::function< void()> &worker_teardown_cb=nullptr)
void apply_all(std::function< void(std::shared_ptr< logger >)> fun)
void set_formatter(formatter_ptr f)
std::shared_ptr< spdlog::formatter > formatter_ptr
void drop(const std::string &name)
std::shared_ptr< sinks::sink > sink_ptr
void set_pattern(const std::string &format_string)
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
void set_error_handler(log_err_handler)
std::shared_ptr< logger > get(const std::string &name)
std::shared_ptr< logger > stdout_color_mt(const std::string &logger_name)
std::shared_ptr< logger > stderr_color_st(const std::string &logger_name)
std::shared_ptr< logger > daily_logger_st(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0)
std::shared_ptr< logger > daily_logger_mt(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0)
std::shared_ptr< logger > create(const std::string &logger_name, const sink_ptr &sink)
std::shared_ptr< logger > create_async(const std::string &logger_name, const sink_ptr &sink, size_t queue_size, const async_overflow_policy overflow_policy=async_overflow_policy::block_retry, const std::function< void()> &worker_warmup_cb=nullptr, const std::chrono::milliseconds &flush_interval_ms=std::chrono::milliseconds::zero(), const std::function< void()> &worker_teardown_cb=nullptr)
void register_logger(std::shared_ptr< logger > logger)
std::shared_ptr< logger > stderr_logger_st(const std::string &logger_name)
std::shared_ptr< logger > basic_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate=false)
std::shared_ptr< logger > stdout_logger_mt(const std::string &logger_name)
std::initializer_list< sink_ptr > sinks_init_list
static registry_t< Mutex > & instance()
std::shared_ptr< logger > stderr_logger_mt(const std::string &logger_name)
std::shared_ptr< logger > stdout_color_st(const std::string &logger_name)
std::shared_ptr< logger > rotating_logger_mt(const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files)
std::function< void(const std::string &err_msg)> log_err_handler
std::shared_ptr< logger > stderr_color_mt(const std::string &logger_name)
std::shared_ptr< logger > rotating_logger_st(const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files)
std::shared_ptr< logger > stdout_logger_st(const std::string &logger_name)
void set_level(level::level_enum log_level)
std::shared_ptr< logger > basic_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate=false)