userver: userver/components/logging_configurator.hpp Source File
Loading...
Searching...
No Matches
logging_configurator.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/components/logging_configurator.hpp
4/// @brief @copybrief components::LoggingConfigurator
5
6#include <userver/components/component_fwd.hpp>
7#include <userver/components/raw_component_base.hpp>
8#include <userver/concurrent/async_event_source.hpp>
9#include <userver/utils/statistics/fwd.hpp>
10
11#include <dynamic_config/variables/USERVER_LOG_DYNAMIC_DEBUG.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace logging {
16struct DynamicDebugConfig;
17}
18
19namespace components {
20
21/// @ingroup userver_components
22///
23/// @brief Helper component to configure logging.
24///
25/// The functionality is not in Trace or Logger components because that
26/// introduces circular dependency between Logger and DynamicConfig.
27///
28/// ## LoggingConfigurator Dynamic config
29/// * @ref USERVER_LOG_DYNAMIC_DEBUG
30/// * @ref USERVER_NO_LOG_SPANS
31///
32/// ## Static options of components::LoggingConfigurator :
33/// @include{doc} scripts/docs/en/components_schema/core/src/components/logging_configurator.md
34///
35/// Options inherited from @ref components::ComponentBase :
36/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
37///
38/// ## Config example:
39///
40/// @snippet components/common_component_list_test.cpp Sample logging configurator component config
41class LoggingConfigurator final : public RawComponentBase {
42public:
43 /// @ingroup userver_component_names
44 /// @brief The default name of @ref components::LoggingConfigurator component
45 static constexpr std::string_view kName = "logging-configurator";
46
47 LoggingConfigurator(const ComponentConfig& config, const ComponentContext& context);
48
49 ~LoggingConfigurator() override;
50
51 static yaml_config::Schema GetStaticConfigSchema();
52
53private:
54 void OnConfigUpdate(const dynamic_config::Snapshot& config);
55
56 utils::statistics::MetricsStoragePtr metrics_storage_;
57 // config_subscription_ must be the last field!
58 concurrent::AsyncEventSubscriberScope config_subscription_;
59};
60
61/// }@
62
63template <>
64inline constexpr bool kHasValidate<LoggingConfigurator> = true;
65
66} // namespace components
67
68USERVER_NAMESPACE_END