userver: userver/ugrpc/server/middlewares/log/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
1#pragma once
2
3/// @file userver/ugrpc/server/logging/component.hpp
4/// @brief @copybrief ugrpc::server::middlewares::log::Component
5
6#include <optional>
7
8#include <userver/ugrpc/server/middlewares/base.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12/// Server logging middleware
13namespace ugrpc::server::middlewares::log {
14
15// clang-format off
16
17/// @ingroup userver_components userver_base_classes
18///
19/// @brief Component for gRPC server logging
20///
21/// ## Static options:
22/// Name | Description | Default value
23/// ---- | ----------- | -------------
24/// log-level | log level for msg logging | debug
25/// msg-size-log-limit | max message size to log, the rest will be truncated | 512
26
27// clang-format on
28
29class Component final : public MiddlewareComponentBase {
30 public:
31 /// @ingroup userver_component_names
32 /// @brief The default name of ugrpc::server::middlewares::log::Component
33 static constexpr std::string_view kName = "grpc-server-logging";
34
35 Component(const components::ComponentConfig& config,
36 const components::ComponentContext& context);
37
38 std::shared_ptr<MiddlewareBase> GetMiddleware() override;
39
40 static yaml_config::Schema GetStaticConfigSchema();
41
42 private:
43 std::size_t max_size_;
44 logging::Level msg_log_level_;
45 std::optional<logging::Level> local_log_level_;
46};
47
48} // namespace ugrpc::server::middlewares::log
49
50USERVER_NAMESPACE_END