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