userver: userver/server/handlers/on_log_rotate.hpp Source File
Loading...
Searching...
No Matches
on_log_rotate.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/handlers/on_log_rotate.hpp
4/// @brief @copybrief server::handlers::OnLogRotate
5
6#include <userver/server/handlers/http_handler_base.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace components {
11class Logging;
12} // namespace components
13
14namespace server::handlers {
15
16/// @ingroup userver_components userver_http_handlers
17///
18/// @brief Handler that controls logging levels of all the loggers.
19///
20/// The component has no service configuration except the
21/// @ref userver_http_handlers "common handler options".
22///
23/// ## Static configuration example:
24///
25/// @snippet components/common_server_component_list_test.cpp Sample handler log level component config
26///
27/// ## Scheme
28/// POST request reopens log file for all loggers.
29/// Returns 200 status code after successful operation.
30/// If at least one of files was not successfully reopened returns 500 status
31/// code and error messages separated by comma in response body.
32class OnLogRotate final : public HttpHandlerBase {
33public:
34 OnLogRotate(const components::ComponentConfig& config, const components::ComponentContext& component_context);
35
36 /// @ingroup userver_component_names
37 /// @brief The default name of server::handlers::OnLogRotate
38 static constexpr std::string_view kName = "handler-on-log-rotate";
39
40 std::string HandleRequestThrow(const http::HttpRequest& request, request::RequestContext&) const override;
41
42 static yaml_config::Schema GetStaticConfigSchema();
43
44private:
45 components::Logging& logging_component_;
46};
47
48} // namespace server::handlers
49
50template <>
51inline constexpr bool components::kHasValidate<server::handlers::OnLogRotate> = true;
52
53USERVER_NAMESPACE_END