userver: userver/ugrpc/server/middlewares/log/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/ugrpc/server/middlewares/log/component.hpp
4/// @brief @copybrief ugrpc::server::middlewares::log::Component
5
6#include <userver/ugrpc/server/middlewares/base.hpp>
7#include <userver/utils/box.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11/// Server logging middleware
12namespace ugrpc::server::middlewares::log {
13
14struct Settings;
15
16// clang-format off
17
18/// @ingroup userver_components userver_base_classes
19///
20/// @brief Component for gRPC server logging
21///
22/// ## Static options:
23/// Name | Description | Default value
24/// ---- | ----------- | -------------
25/// log-level | log level for msg logging | debug
26/// msg-log-level | gRPC message body logging level | debug
27/// msg-size-log-limit | max message size to log, the rest will be truncated | 512
28/// trim-secrets | trim the secrets from logs as marked by the protobuf option | true (*)
29///
30/// @warning * Trimming secrets causes a segmentation fault for messages that contain
31/// optional fields in protobuf versions prior to 3.13. You should set trim-secrets to false
32/// if this is the case for you. See https://github.com/protocolbuffers/protobuf/issues/7801
33///
34/// ## Static configuration example:
35///
36/// @snippet grpc/functional_tests/basic_chaos/static_config.yaml Sample grpc server logging middleware component config
37
38// clang-format on
39
40class Component final : public MiddlewareComponentBase {
41public:
42 /// @ingroup userver_component_names
43 /// @brief The default name of ugrpc::server::middlewares::log::Component
44 static constexpr std::string_view kName = "grpc-server-logging";
45
46 Component(const components::ComponentConfig& config, const components::ComponentContext& context);
47
48 ~Component() override;
49
50 std::shared_ptr<MiddlewareBase> GetMiddleware() override;
51
52 static yaml_config::Schema GetStaticConfigSchema();
53
54private:
55 const utils::Box<Settings> settings_;
56};
57
58} // namespace ugrpc::server::middlewares::log
59
60USERVER_NAMESPACE_END