27#include <unordered_map>
28#include <unordered_set>
31#include <fmt/format.h>
53 std::make_shared<default_log_sink_factory>());
63 const std::shared_ptr<log_sink_factory_base>& sink_factory) {
64 if (!
caches_.try_emplace(name, sink_factory).second) {
66 "Duplicate configurations of a log sink {}.", name));
78 const auto iter =
caches_.find(name);
80 throw std::invalid_argument(
81 fmt::format(
"Log sink {} not found.", name));
83 auto sink = iter->second.get(*
this);
119 std::optional<sinks::log_sink>
sink_;
131 fmt::format(
"Loop of references of log sinks in configurations "
132 "detected for log sink {}.",
148 std::unordered_map<std::string, cached_log_sink>
caches_{};
Class of exception on invalid arguments.
Class of caches of log sinks.
auto get(log_sink_factory_table &sinks) -> sinks::log_sink
Get the log sink creating it if needed.
std::optional< sinks::log_sink > sink_
Log sink.
cached_log_sink(std::shared_ptr< log_sink_factory_base > factory)
Constructor.
std::shared_ptr< log_sink_factory_base > factory_
Factory of the log sink.
Class of tables of log sinks.
void check_sink_reference_loop(std::string name)
Check whether a log sink can be created without loop of references.
void append(const std::string &name, const std::shared_ptr< log_sink_factory_base > &sink_factory)
Append a factory of a log sink.
std::unordered_set< std::string > currently_creating_sink_names_
Names of currently creating sinks.
void pop_created_log_sink_name(const std::string &name)
Pop a name of a created log sink from currently_creating_sink_names_.
auto get(const std::string &name) -> sinks::log_sink
Get a log sink creating it if needed.
log_sink_factory_table()
Constructor.
std::unordered_map< std::string, cached_log_sink > caches_
Caches.
Definition of default_log_sink_factory class.
Definition of exceptions.
Definition of log_sink class.
Definition of log_sink_factory_base class.
Namespace of logging configuration.
constexpr auto default_log_sink_name
Name of the default log sink.