userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
log_level.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/server/handlers/log_level.hpp
4
/// @brief @copybrief server::handlers::LogLevel
5
6
#
include
<
userver
/
concurrent
/
variable
.
hpp
>
7
#
include
<
userver
/
logging
/
level
.
hpp
>
8
#
include
<
userver
/
server
/
handlers
/
http_handler_base
.
hpp
>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
components
{
13
class
Logging;
14
}
// namespace components
15
16
namespace
server::
handlers
{
17
/// @ingroup userver_components userver_http_handlers
18
///
19
/// @brief Handler that controls logging levels of all the loggers.
20
///
21
/// The component has no service configuration except the
22
/// @ref userver_http_handlers "common handler options".
23
///
24
/// ## Static configuration example:
25
///
26
/// @snippet components/common_server_component_list_test.cpp Sample handler log level component config
27
///
28
/// ## Scheme
29
/// For the GET and PUT requests this handler returns the following JSON:
30
/// @code
31
/// {
32
/// "init-log-level": <log level on service start>,
33
/// "current-log-level": <current log level>
34
/// }
35
/// @endcode
36
///
37
/// Particular logger name could be specified by an optional `logger` query
38
/// argument. Default logger is used, if no `logger` was provided.
39
///
40
/// PUT request changes the logger level to the value specified in the `level`
41
/// query argument. Set it to the `reset` value, to reset the logger level to
42
/// the initial values.
43
///
44
/// @see @ref scripts/docs/en/userver/log_level_running_service.md
45
class
LogLevel
final
:
public
HttpHandlerBase
{
46
public
:
47
LogLevel(
const
components
::ComponentConfig& config,
const
components
::ComponentContext& component_context);
48
49
/// @ingroup userver_component_names
50
/// @brief The default name of server::handlers::LogLevel
51
static
constexpr
std::string_view
kName
=
"handler-log-level"
;
52
53
std::string
HandleRequestThrow
(
const
http
::HttpRequest& request,
request
::RequestContext&)
const
override
;
54
55
static
yaml_config::Schema GetStaticConfigSchema();
56
57
private
:
58
std::string ProcessGet(
const
http
::HttpRequest& request,
request
::RequestContext&)
const
;
59
std::string ProcessPut(
const
http
::HttpRequest& request,
request
::RequestContext&)
const
;
60
61
components
::Logging& logging_component_;
62
struct
Data {
63
logging::
Level
default_init_level;
64
mutable
std::unordered_map<std::string, logging::
Level
> init_levels;
65
};
66
concurrent
::Variable<Data> data_;
67
};
68
69
}
// namespace server::handlers
70
71
template
<>
72
inline
constexpr
bool
components
::kHasValidate<server::handlers::LogLevel> =
true
;
73
74
USERVER_NAMESPACE_END
userver
server
handlers
log_level.hpp
Generated on
for userver by
Doxygen
1.17.0