Agora
1.2.0
Agora project
|
Go to the documentation of this file.
6 #ifndef SPDLOG_HEADER_ONLY
15 #ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
22 #endif // SPDLOG_DISABLE_DEFAULT_LOGGER
28 #include <unordered_map>
37 #ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
40 auto color_sink = std::make_shared<sinks::wincolor_stdout_sink_mt>();
42 auto color_sink = std::make_shared<sinks::ansicolor_stdout_sink_mt>();
45 const char *default_logger_name =
"";
46 default_logger_ = std::make_shared<spdlog::logger>(default_logger_name, std::move(color_sink));
49 #endif // SPDLOG_DISABLE_DEFAULT_LOGGER
63 new_logger->set_formatter(
formatter_->clone());
73 new_logger->set_level(new_level);
91 auto found =
loggers_.find(logger_name);
92 return found ==
loggers_.end() ? nullptr : found->second;
120 if (new_default_logger !=
nullptr)
122 loggers_[new_default_logger->name()] = new_default_logger;
129 std::lock_guard<std::recursive_mutex> lock(
tp_mutex_);
135 std::lock_guard<std::recursive_mutex> lock(
tp_mutex_);
157 l.second->enable_backtrace(n_messages);
167 l.second->disable_backtrace();
176 l.second->set_level(log_level);
186 l.second->flush_on(log_level);
194 auto clbk = [
this]() { this->
flush_all(); };
203 l.second->set_error_handler(handler);
254 std::lock_guard<std::recursive_mutex> lock(
tp_mutex_);
274 auto global_level_requested = global_level !=
nullptr;
284 else if (global_level_requested)
301 throw_spdlog_ex(
"logger with name '" + logger_name +
"' already exists");
307 auto logger_name = new_logger->name();
309 loggers_[logger_name] = std::move(new_logger);
std::unordered_map< std::string, std::shared_ptr< logger > > loggers_
Definition: registry.h:97
logger * get_default_raw()
Definition: registry-inl.h:105
void disable_backtrace()
Definition: registry-inl.h:161
bool automatic_registration_
Definition: registry.h:106
log_levels log_levels_
Definition: registry.h:98
level::level_enum flush_level_
Definition: registry.h:101
std::shared_ptr< thread_pool > tp_
Definition: registry.h:103
void flush_all()
Definition: registry-inl.h:217
Definition: registry.h:27
void set_formatter(std::unique_ptr< formatter > formatter)
Definition: registry-inl.h:140
level_enum
Definition: common.h:211
void set_level(level::level_enum log_level)
Definition: logger-inl.h:67
void apply_all(const std::function< void(const std::shared_ptr< logger >)> &fun)
Definition: registry-inl.h:208
err_handler err_handler_
Definition: registry.h:102
void register_logger(std::shared_ptr< logger > new_logger)
Definition: registry-inl.h:54
std::shared_ptr< logger > get(const std::string &logger_name)
Definition: registry-inl.h:88
void flush_every(std::chrono::seconds interval)
Definition: registry-inl.h:191
void drop(const std::string &logger_name)
Definition: registry-inl.h:226
void set_error_handler(err_handler handler)
Definition: registry-inl.h:198
std::unordered_map< std::string, level::level_enum > log_levels
Definition: registry.h:30
SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno)
Definition: common-inl.h:72
std::mutex flusher_mutex_
Definition: registry.h:95
void set_levels(log_levels levels, level::level_enum *global_level)
Definition: registry-inl.h:270
void initialize_logger(std::shared_ptr< logger > new_logger)
Definition: registry-inl.h:60
void set_default_logger(std::shared_ptr< logger > new_default_logger)
Definition: registry-inl.h:112
void enable_backtrace(size_t n_messages)
Definition: registry-inl.h:150
std::mutex logger_map_mutex_
Definition: registry.h:95
#define SPDLOG_INLINE
Definition: common.h:42
spdlog::level::level_enum global_log_level_
Definition: registry.h:100
std::shared_ptr< logger > default_logger()
Definition: registry-inl.h:95
void set_level(level::level_enum log_level)
Definition: registry-inl.h:171
std::unique_ptr< periodic_worker > periodic_flusher_
Definition: registry.h:104
std::function< void(const std::string &err_msg)> err_handler
Definition: common.h:129
std::unique_ptr< formatter > formatter_
Definition: registry.h:99
function[avg_proc_duration, std_proc_duration]
Definition: parse_dl_file.m:1
registry()
Definition: registry-inl.h:33
size_t backtrace_n_messages_
Definition: registry.h:107
void drop_all()
Definition: registry-inl.h:236
void set_tp(std::shared_ptr< thread_pool > tp)
Definition: registry-inl.h:127
void flush_on(level::level_enum log_level)
Definition: registry-inl.h:181
void register_logger_(std::shared_ptr< logger > new_logger)
Definition: registry-inl.h:305
l
Definition: parse_all_dl.m:71
void throw_if_exists_(const std::string &logger_name)
Definition: registry-inl.h:297
void set_automatic_registration(bool automatic_registration)
Definition: registry-inl.h:264
std::shared_ptr< logger > default_logger_
Definition: registry.h:105
std::shared_ptr< thread_pool > get_tp()
Definition: registry-inl.h:133
void shutdown()
Definition: registry-inl.h:244
std::recursive_mutex tp_mutex_
Definition: registry.h:96
std::recursive_mutex & tp_mutex()
Definition: registry-inl.h:259
static registry & instance()
Definition: registry-inl.h:291