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/utils/statistics/fwd.hpp>
9
10#include <dynamic_config/variables/USERVER_LOG_DYNAMIC_DEBUG.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace logging {
15struct DynamicDebugConfig;
16}
17
18namespace components {
19
20/// @ingroup userver_components
21///
22/// @brief Helper component to configure logging.
23///
24/// The functionality is not in Trace or Logger components because that
25/// introduces circular dependency between Logger and DynamicConfig.
26///
27/// ## LoggingConfigurator Dynamic config
28/// * @ref USERVER_LOG_DYNAMIC_DEBUG
29/// * @ref USERVER_NO_LOG_SPANS
30///
31/// ## Static options of components::LoggingConfigurator :
32/// @include{doc} scripts/docs/en/components_schema/core/src/components/logging_configurator.md
33///
34/// Options inherited from @ref components::ComponentBase :
35/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
36///
37/// ## Config example:
38///
39/// @snippet core/src/components/common_component_list_test.cpp Sample logging configurator component config
40class LoggingConfigurator final : public RawComponentBase {
41public:
42 /// @ingroup userver_component_names
43 /// @brief The default name of @ref components::LoggingConfigurator component
44 static constexpr std::string_view kName = "logging-configurator";
45
46 LoggingConfigurator(const ComponentConfig& config, const ComponentContext& context);
47
48 static yaml_config::Schema GetStaticConfigSchema();
49
50private:
51 void OnConfigUpdate(const dynamic_config::Snapshot& config);
52
53 utils::statistics::MetricsStoragePtr metrics_storage_;
54};
55
56/// }@
57
58template <>
59inline constexpr bool kHasValidate<LoggingConfigurator> = true;
60
61} // namespace components
62
63USERVER_NAMESPACE_END