7#include <unordered_map>
9#include <userver/components/component_fwd.hpp>
10#include <userver/components/raw_component_base.hpp>
11#include <userver/concurrent/async_event_source.hpp>
12#include <userver/os_signals/component.hpp>
14#include <userver/rcu/rcu_map.hpp>
15#include <userver/utils/fast_pimpl.hpp>
16#include <userver/utils/periodic_task.hpp>
17#include <userver/utils/statistics/metrics_storage.hpp>
18#include <userver/utils/statistics/writer.hpp>
22USERVER_NAMESPACE_BEGIN
24namespace logging::impl {
83class Logging
final :
public RawComponentBase {
87 static constexpr std::string_view
kName =
"logging";
90 Logging(
const ComponentConfig&,
const ComponentContext&);
97 logging::LoggerPtr
GetLogger(
const std::string& name);
109 void SetLogger(
const std::string& name, logging::LoggerPtr logger);
116 void StartSocketLoggingDebug(
const std::optional<logging::Level>& log_level);
117 void StopSocketLoggingDebug(
const std::optional<logging::Level>& log_level);
121 void TryReopenFiles();
123 void WriteStatistics(utils::statistics::Writer& writer)
const;
125 static yaml_config::Schema GetStaticConfigSchema();
128 void Init(
const ComponentConfig&,
const ComponentContext&);
129 void Stop()
noexcept;
133 engine::TaskProcessor& fs_task_processor_;
134 std::unordered_map<std::string, std::shared_ptr<logging::impl::TpLogger>> loggers_;
135 rcu::RcuMap<std::string, logging::LoggerPtr> extra_loggers_;
136 utils::PeriodicTask flush_task_;
137 logging::impl::TcpSocketSink* socket_sink_{
nullptr};
138 utils::statistics::MetricsStoragePtr metrics_storage_;
145inline constexpr bool kHasValidate<Logging> =
true;