userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <memory>
7
#include <string>
8
#include <unordered_map>
9
10
#include <
userver/components/component_fwd.hpp
>
11
#include <
userver/components/raw_component_base.hpp
>
12
#include <
userver/engine/task/task_processor_fwd.hpp
>
13
#include <
userver/rcu/rcu_map.hpp
>
14
#include <
userver/utils/fast_pimpl.hpp
>
15
#include <
userver/utils/periodic_task.hpp
>
16
#include <
userver/utils/statistics/metrics_storage.hpp
>
17
#include <
userver/utils/statistics/writer.hpp
>
18
19
#include "
logger.hpp
"
20
21
USERVER_NAMESPACE_BEGIN
22
23
namespace
logging
{
24
struct
TelemetrySettings
;
25
}
26
27
namespace
utils
{
28
template
<
typename
ValueType>
29
class
DefaultDict
;
30
}
31
32
namespace
logging::impl {
33
class
TpLogger;
34
class
TcpSocketSink;
35
class
TelemetrySettingsStorage;
36
}
// namespace logging::impl
37
38
namespace
components
{
39
40
// clang-format off
41
89
90
// clang-format on
91
92
class
Logging
final :
public
RawComponentBase {
93
public
:
96
static
constexpr
std::string_view
kName
=
"logging"
;
97
99
Logging
(
const
ComponentConfig
&,
const
ComponentContext
&);
100
~Logging
()
override
;
101
106
logging::LoggerPtr
GetLogger
(
const
std::string& name);
107
113
logging::TextLoggerPtr
GetTextLogger
(
const
std::string& name);
114
121
void
SetLogger
(
const
std::string& name, logging::LoggerPtr logger);
122
128
void
SetTelemetrySettings
(
129
utils::DefaultDict<logging::TelemetrySettings>
settings,
130
utils::DefaultDict<logging::TelemetrySettings>
restrictions
131
);
132
135
void
RestoreTelemetrySettings
();
136
140
logging::LoggerPtr
GetLoggerOptional
(
const
std::string& name);
141
142
void
StartSocketLoggingDebug(
const
std::optional<logging::Level>& log_level);
143
void
StopSocketLoggingDebug(
const
std::optional<logging::Level>& log_level);
144
146
void
OnLogRotate
();
147
void
TryReopenFiles();
148
149
void
WriteStatistics(
utils::statistics::Writer
& writer)
const
;
150
151
static
yaml_config::Schema
GetStaticConfigSchema();
152
153
private
:
154
void
Init(
const
ComponentConfig
&,
const
ComponentContext
&);
155
void
Stop() noexcept;
156
157
void
FlushLogs();
158
159
engine
::
TaskProcessor
& fs_task_processor_;
160
std
::unordered_map<
std
::
string
,
std
::shared_ptr<
logging
::impl::TpLogger>> loggers_;
161
rcu
::RcuMap<
std
::
string
,
logging
::LoggerPtr> extra_loggers_;
162
const
std
::unique_ptr<
logging
::impl::TelemetrySettingsStorage> telemetry_settings_;
163
utils
::PeriodicTask flush_task_;
164
logging
::impl::TcpSocketSink* socket_sink_{
nullptr
};
165
utils::statistics::MetricsStoragePtr metrics_storage_;
166
};
167
168
template
<>
169
inline
constexpr
bool
kHasValidate<Logging> =
true
;
170
171
}
// namespace components
172
173
USERVER_NAMESPACE_END
userver
logging
component.hpp
Generated on
for userver by
Doxygen
1.17.0