userver: userver/server/handlers/on_log_rotate.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 {
36 public:
37 OnLogRotate(const components::ComponentConfig& config,
38 const components::ComponentContext& component_context);
39
40 /// @ingroup userver_component_names
41 /// @brief The default name of server::handlers::OnLogRotate
42 static constexpr std::string_view kName = "handler-on-log-rotate";
43
44 std::string HandleRequestThrow(const http::HttpRequest& request,
45 request::RequestContext&) const override;
46
47 static yaml_config::Schema GetStaticConfigSchema();
48
49 private:
50 components::Logging& logging_component_;
51};
52
53} // namespace server::handlers
54
55template <>
56inline constexpr bool components::kHasValidate<server::handlers::OnLogRotate> =
57 true;
58
59USERVER_NAMESPACE_END