userver
C++ Async Framework
Toggle main menu visibility
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
<
memory
>
7
#
include
<
string_view
>
8
9
#
include
<
userver
/
components
/
component_fwd
.
hpp
>
10
#
include
<
userver
/
components
/
raw_component_base
.
hpp
>
11
#
include
<
userver
/
dynamic_config
/
fwd
.
hpp
>
12
#
include
<
userver
/
utils
/
statistics
/
fwd
.
hpp
>
13
14
#
include
<
dynamic_config
/
variables
/
USERVER_LOG_DYNAMIC_DEBUG
.
hpp
>
15
16
USERVER_NAMESPACE_BEGIN
17
18
namespace
logging
{
19
struct
DynamicDebugConfig;
20
struct
TelemetryConfig;
21
}
// namespace logging
22
23
namespace
components
{
24
25
/// @ingroup userver_components
26
///
27
/// @brief Helper component to configure logging.
28
///
29
/// The functionality is not in Trace or Logger components because that
30
/// introduces circular dependency between Logger and DynamicConfig.
31
///
32
/// ## LoggingConfigurator Dynamic config
33
/// * @ref USERVER_LOG_DYNAMIC_DEBUG
34
/// * @ref USERVER_NO_LOG_SPANS
35
/// * @ref USERVER_TELEMETRY_SETTINGS
36
///
37
/// ## Static options of components::LoggingConfigurator :
38
/// @include{doc} scripts/docs/en/components_schema/core/src/components/logging_configurator.md
39
///
40
/// Options inherited from @ref components::ComponentBase :
41
/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
42
///
43
/// ## Config example:
44
///
45
/// @snippet core/src/components/common_component_list_test.cpp Sample logging configurator component config
46
class
LoggingConfigurator
final
:
public
RawComponentBase
{
47
public
:
48
/// @ingroup userver_component_names
49
/// @brief The default name of @ref components::LoggingConfigurator component
50
static
constexpr
std::string_view
kName
=
"logging-configurator"
;
51
52
LoggingConfigurator(
const
ComponentConfig& config,
const
ComponentContext& context);
53
54
~LoggingConfigurator()
override
;
55
56
/// Replaces the process's single external policy and applies the stricter settings
57
/// from it and @ref USERVER_TELEMETRY_SETTINGS. An empty policy removes external restrictions.
58
/// Calls are synchronized with dynamic config updates. The caller must stop its
59
/// subscriptions and clear its policy before this component is destroyed.
60
/// @throws std::runtime_error for invalid sampling rates, without changing the policy.
61
void
SetRestrictions
(
logging
::TelemetryConfig restrictions);
62
63
static
yaml_config::Schema GetStaticConfigSchema();
64
65
private
:
66
class
TelemetryState;
67
68
void
OnConfigUpdate(
const
dynamic_config::Diff& diff);
69
70
utils
::
statistics
::MetricsStoragePtr metrics_storage_;
71
const
std::unique_ptr<TelemetryState> telemetry_;
72
};
73
74
/// }@
75
76
template
<>
77
inline
constexpr
bool
kHasValidate
<
LoggingConfigurator
> =
true
;
78
79
}
// namespace components
80
81
USERVER_NAMESPACE_END
userver
components
logging_configurator.hpp
Generated on
for userver by
Doxygen
1.17.0