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// clang-format off
16
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/// POST request reopens log file for all loggers.
30/// Returns 200 status code after successful operation.
31/// If at least one of files was not successfully reopened returns 500 status
32/// code and error messages separated by comma in response body.
33
34// clang-format on
35class OnLogRotate final : public HttpHandlerBase {
36public:
37 OnLogRotate(const components::ComponentConfig& config, const components::ComponentContext& component_context);
38
39 /// @ingroup userver_component_names
40 /// @brief The default name of server::handlers::OnLogRotate
41 static constexpr std::string_view kName = "handler-on-log-rotate";
42
43 std::string HandleRequestThrow(const http::HttpRequest& request, request::RequestContext&) const override;
44
45 static yaml_config::Schema GetStaticConfigSchema();
46
47private:
48 components::Logging& logging_component_;
49};
50
51} // namespace server::handlers
52
53template <>
54inline constexpr bool components::kHasValidate<server::handlers::OnLogRotate> = true;
55
56USERVER_NAMESPACE_END